Added API for SKBitmap.ExtractAlpha

This commit is contained in:
Matthew Leibowitz 2017-02-06 13:56:44 -06:00
Родитель 929be1c401
Коммит bc064d5109
4 изменённых файлов: 48 добавлений и 1 удалений

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

@ -179,6 +179,31 @@ namespace SkiaSharp
return SkiaApi.sk_bitmap_extract_subset (Handle, destination.Handle, ref subset);
}
public bool ExtractAlpha(SKBitmap destination)
{
SKPointI offset;
return ExtractAlpha (destination, null, out offset);
}
public bool ExtractAlpha(SKBitmap destination, out SKPointI offset)
{
return ExtractAlpha (destination, null, out offset);
}
public bool ExtractAlpha(SKBitmap destination, SKPaint paint)
{
SKPointI offset;
return ExtractAlpha (destination, paint, out offset);
}
public bool ExtractAlpha(SKBitmap destination, SKPaint paint, out SKPointI offset)
{
if (destination == null) {
throw new ArgumentNullException (nameof (destination));
}
return SkiaApi.sk_bitmap_extract_alpha (Handle, destination.Handle, paint == null ? IntPtr.Zero : paint.Handle, out offset);
}
public bool ReadyToDraw => SkiaApi.sk_bitmap_ready_to_draw (Handle);
public SKImageInfo Info {

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

@ -1221,6 +1221,9 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_extract_subset(sk_bitmap_t cbitmap, sk_bitmap_t cdst, ref SKRectI subset);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_extract_alpha(sk_bitmap_t cbitmap, sk_bitmap_t dst, sk_paint_t paint, out SKPointI offset);
// SkPixmap

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 21d14eb3d5b3389859f1648fbd9e1bac80553bbf
Subproject commit d44a5051d62783ef9440658f987bb6a1eca59b2b

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

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using Xunit;
@ -39,6 +40,24 @@ namespace SkiaSharp.Tests
Marshal.FreeCoTaskMem(pixels);
}
[Fact]
public void TestExtractAlpha()
{
var path = Path.Combine(PathToImages, "color-wheel.png");
var bitmap = SKBitmap.Decode(path);
var alpha = new SKBitmap();
SKPointI offset;
SKPaint paint = new SKPaint {
MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 5.0f)
};
Assert.True(bitmap.ExtractAlpha(alpha, paint, out offset));
Assert.Equal(new SKPointI(-7, -7), offset);
}
[Fact]
public void BitmapAndPixmapAreValid()
{