SKImage.ToBitmap is now SKBitmap.FromImage:

- avoid conflicts with Android extension methods
 - reduce discoverability of SKBitmap (deprecating) with SKImage
This commit is contained in:
Matthew Leibowitz 2017-02-26 04:15:30 +02:00
Родитель 39d7166945
Коммит 022209b001
3 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -544,6 +544,23 @@ namespace SkiaSharp
} }
} }
public static SKBitmap FromImage (SKImage image)
{
if (image == null) {
throw new ArgumentNullException (nameof (image));
}
var info = new SKImageInfo (image.Width, image.Height, SKImageInfo.PlatformColorType, image.AlphaType);
var bmp = new SKBitmap (info);
if (!image.ReadPixels (info, bmp.GetPixels (), info.RowBytes, 0, 0))
{
bmp.Dispose ();
bmp = null;
}
return bmp;
}
// internal proxy // internal proxy
#if __IOS__ #if __IOS__
[ObjCRuntime.MonoPInvokeCallback (typeof (SKBitmapReleaseDelegateInternal))] [ObjCRuntime.MonoPInvokeCallback (typeof (SKBitmapReleaseDelegateInternal))]

Просмотреть файл

@ -368,18 +368,6 @@ namespace SkiaSharp
return GetObject<SKImage> (SkiaApi.sk_image_make_with_filter (Handle, filter.Handle, ref subset, ref clipBounds, out outSubset, out outOffset)); return GetObject<SKImage> (SkiaApi.sk_image_make_with_filter (Handle, filter.Handle, ref subset, ref clipBounds, out outSubset, out outOffset));
} }
public SKBitmap ToBitmap ()
{
var info = new SKImageInfo (Width, Height, SKImageInfo.PlatformColorType, AlphaType);
var bmp = new SKBitmap (info);
if (!ReadPixels (info, bmp.GetPixels (), info.RowBytes, 0, 0))
{
bmp.Dispose ();
bmp = null;
}
return bmp;
}
// internal proxies // internal proxies

Просмотреть файл

@ -119,7 +119,7 @@ namespace SkiaSharp.Views.Mac
public static CGImage ToCGImage(this SKImage skiaImage) public static CGImage ToCGImage(this SKImage skiaImage)
{ {
var bmp = skiaImage.ToBitmap(); var bmp = SKBitmap.FromImage(skiaImage);
return bmp.ToCGImage(); return bmp.ToCGImage();
} }
@ -215,7 +215,7 @@ namespace SkiaSharp.Views.Mac
public static NSData ToNSData(this SKData skiaData) public static NSData ToNSData(this SKData skiaData)
{ {
return new NSData(skiaData.Data, (nuint)skiaData.Size, null); return NSData.FromBytes(skiaData.Data, (nuint)skiaData.Size);
} }
public static SKData ToSKData(this NSData nsData) public static SKData ToSKData(this NSData nsData)