Added a member to swizzle the R and B
This commit is contained in:
Родитель
999425f2d5
Коммит
8ddb0f6668
|
@ -55,5 +55,6 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)SKVertices.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKManagedPixelSerializer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKPixelSerializer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SKSwizzle.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// Bindings for Skia's swizzle features
|
||||
//
|
||||
// Author:
|
||||
// Matthew Leibowitz
|
||||
//
|
||||
// Copyright 2017 Xamarin Inc
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public static class SKSwizzle
|
||||
{
|
||||
public static void SwapRedBlue (IntPtr dest, IntPtr src, int count)
|
||||
{
|
||||
if (dest == IntPtr.Zero) {
|
||||
throw new ArgumentException (nameof (dest));
|
||||
}
|
||||
if (src == IntPtr.Zero) {
|
||||
throw new ArgumentException (nameof (src));
|
||||
}
|
||||
|
||||
SkiaApi.sk_swizzle_swap_rb (dest, src, count);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1398,6 +1398,9 @@ namespace SkiaSharp
|
|||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public extern static bool sk_pixmap_read_pixels(sk_pixmap_t cpixmap, ref SKImageInfoNative dstInfo, IntPtr dstPixels, IntPtr dstRowBytes, int srcX, int srcY);
|
||||
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static void sk_swizzle_swap_rb(IntPtr dest, IntPtr src, int count);
|
||||
|
||||
// Mask
|
||||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
public extern static IntPtr sk_mask_alloc_image(IntPtr bytes);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ddeb7dcf52e6099a8192adbdbd442a517b5d25c9
|
||||
Subproject commit 7dd04f34629f406059aa22daecb673fef4561577
|
|
@ -389,5 +389,21 @@ namespace SkiaSharp.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SwizzleRedBlueTest()
|
||||
{
|
||||
var info = new SKImageInfo(1, 1);
|
||||
|
||||
using (var bmp = new SKBitmap(info))
|
||||
{
|
||||
bmp.Erase((uint)0xFACEB004);
|
||||
|
||||
Assert.AreEqual((uint)0xFACEB004, (uint)bmp.GetPixel(0, 0));
|
||||
|
||||
SKSwizzle.SwapRedBlue(bmp.GetPixels(), bmp.GetPixels(), 1);
|
||||
|
||||
Assert.AreEqual((uint)0xFA04B0CE, (uint)bmp.GetPixel(0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче