From 9483aea5188ebaf81e3965f2121f32e614bdd100 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 24 Aug 2016 01:36:33 +0200 Subject: [PATCH] Marshaling uint32_t as SKColor was causing issues - resolves #143 - only return types caused issues --- binding/Binding/Definitions.cs | 10 ++++++++++ binding/Binding/SkiaApi.cs | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/binding/Binding/Definitions.cs b/binding/Binding/Definitions.cs index a05a27c5e7..8e66cb6095 100644 --- a/binding/Binding/Definitions.cs +++ b/binding/Binding/Definitions.cs @@ -127,6 +127,16 @@ public override int GetHashCode () { return (int) color; } + + public static implicit operator SKColor (uint color) + { + return new SKColor (color); + } + + public static explicit operator uint (SKColor color) + { + return color.color; + } } [Flags] diff --git a/binding/Binding/SkiaApi.cs b/binding/Binding/SkiaApi.cs index 03e903d9f8..3b8b2c3ada 100755 --- a/binding/Binding/SkiaApi.cs +++ b/binding/Binding/SkiaApi.cs @@ -198,7 +198,7 @@ internal static class SkiaApi [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_paint_set_verticaltext(sk_paint_t t, bool v); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static SKColor sk_paint_get_color(sk_paint_t t); + public extern static UInt32 sk_paint_get_color(sk_paint_t t); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_paint_set_color(sk_paint_t t, SKColor color); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] @@ -923,9 +923,9 @@ internal static class SkiaApi [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_bitmap_erase_rect(sk_bitmap_t cbitmap, SKColor color, ref SKRectI rect); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static SKColor sk_bitmap_get_pixel_color(sk_bitmap_t cbitmap, int x, int y); + public extern static UInt32 sk_bitmap_get_pixel_color(sk_bitmap_t cbitmap, int x, int y); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] - public extern static SKColor sk_bitmap_get_index8_color(sk_bitmap_t cbitmap, int x, int y); + public extern static UInt32 sk_bitmap_get_index8_color(sk_bitmap_t cbitmap, int x, int y); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] public extern static void sk_bitmap_set_pixel_color(sk_bitmap_t cbitmap, int x, int y, SKColor color); [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]