SKImage.ToBitmap is now SKBitmap.FromImage:
- avoid conflicts with Android extension methods - reduce discoverability of SKBitmap (deprecating) with SKImage
This commit is contained in:
Родитель
39d7166945
Коммит
022209b001
|
@ -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
|
||||
#if __IOS__
|
||||
[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));
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace SkiaSharp.Views.Mac
|
|||
|
||||
public static CGImage ToCGImage(this SKImage skiaImage)
|
||||
{
|
||||
var bmp = skiaImage.ToBitmap();
|
||||
var bmp = SKBitmap.FromImage(skiaImage);
|
||||
return bmp.ToCGImage();
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ namespace SkiaSharp.Views.Mac
|
|||
|
||||
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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче