Skip to content

Commit

Permalink
Marshaling uint32_t as SKColor was causing issues
Browse files Browse the repository at this point in the history
 - resolves #143
 - only return types caused issues
  • Loading branch information
mattleibow committed Aug 23, 2016
1 parent 0f12502 commit 9483aea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions binding/Binding/Definitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions binding/Binding/SkiaApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 9483aea

Please sign in to comment.