|
2 | 2 | // See the LICENCE file in the repository root for full licence text.
|
3 | 3 |
|
4 | 4 | using System;
|
5 |
| -using System.IO; |
6 | 5 | using System.Runtime.InteropServices;
|
7 |
| -using osu.Framework.Platform.MacOS.Native; |
8 |
| -using SixLabors.ImageSharp; |
9 |
| -using SixLabors.ImageSharp.Formats.Tiff; |
10 |
| -using SixLabors.ImageSharp.PixelFormats; |
11 | 6 |
|
12 | 7 | namespace osu.Framework.Platform.Apple.Native
|
13 | 8 | {
|
@@ -100,48 +95,6 @@ static Interop()
|
100 | 95 | AppKitLibrary = dlopen(LIB_APPKIT, RTLD_NOW);
|
101 | 96 | }
|
102 | 97 |
|
103 |
| - private static readonly IntPtr sel_utf8_string = Selector.Get("UTF8String"); |
104 |
| - private static readonly IntPtr sel_tiff_representation = Selector.Get("TIFFRepresentation"); |
105 |
| - |
106 |
| - public static string? FromNSString(IntPtr handle) => Marshal.PtrToStringUTF8(SendIntPtr(handle, sel_utf8_string)); |
107 |
| - |
108 |
| - public static Image<TPixel>? FromNSImage<TPixel>(IntPtr handle) |
109 |
| - where TPixel : unmanaged, IPixel<TPixel> |
110 |
| - { |
111 |
| - if (handle == IntPtr.Zero) |
112 |
| - return null; |
113 |
| - |
114 |
| - var tiffRepresentation = new NSData(SendIntPtr(handle, sel_tiff_representation)); |
115 |
| - return Image.Load<TPixel>(tiffRepresentation.ToBytes()); |
116 |
| - } |
117 |
| - |
118 |
| - public static unsafe IntPtr ToNSString(string? str) |
119 |
| - { |
120 |
| - if (str == null) |
121 |
| - return IntPtr.Zero; |
122 |
| - |
123 |
| - fixed (char* ptrFirstChar = str) |
124 |
| - { |
125 |
| - IntPtr handle = SendIntPtr(Class.Get("NSString"), Selector.Get("alloc")); |
126 |
| - return SendIntPtr(handle, Selector.Get("initWithCharacters:length:"), (IntPtr)ptrFirstChar, str.Length); |
127 |
| - } |
128 |
| - } |
129 |
| - |
130 |
| - public static IntPtr ToNSImage(Image? image) |
131 |
| - { |
132 |
| - if (image == null) |
133 |
| - return IntPtr.Zero; |
134 |
| - |
135 |
| - using (var stream = new MemoryStream()) |
136 |
| - { |
137 |
| - image.Save(stream, TiffFormat.Instance); |
138 |
| - byte[] array = stream.ToArray(); |
139 |
| - |
140 |
| - IntPtr handle = SendIntPtr(Class.Get("NSImage"), Selector.Get("alloc")); |
141 |
| - return SendIntPtr(handle, Selector.Get("initWithData:"), NSData.FromBytes(array)); |
142 |
| - } |
143 |
| - } |
144 |
| - |
145 | 98 | public static IntPtr GetStringConstant(IntPtr handle, string symbol)
|
146 | 99 | {
|
147 | 100 | IntPtr ptr = dlsym(handle, symbol);
|
|
0 commit comments