add guards to setting colortable
This commit is contained in:
Родитель
fd30a3c4c4
Коммит
a07cfc5b3b
|
@ -14,6 +14,8 @@ namespace SkiaSharp
|
|||
{
|
||||
public class SKBitmap : SKObject
|
||||
{
|
||||
const string UNSUPPORTED_CLR_TYPE_MSG = "Setting the ColorTable is only supported for bitmaps with ColorTypes of Index8";
|
||||
|
||||
[Preserve]
|
||||
internal SKBitmap (IntPtr handle, bool owns)
|
||||
: base (handle, owns)
|
||||
|
@ -195,10 +197,18 @@ namespace SkiaSharp
|
|||
}
|
||||
|
||||
public void SetPixels(IntPtr pixels, SKColorTable ct = null) {
|
||||
if (ct != null && ColorType != SKColorType.Index8)
|
||||
{
|
||||
throw new NotSupportedException(UNSUPPORTED_CLR_TYPE_MSG);
|
||||
}
|
||||
SkiaApi.sk_bitmap_set_pixels(Handle, pixels, ct != null ? ct.Handle : IntPtr.Zero);
|
||||
}
|
||||
|
||||
public void SetColorTable(SKColorTable ct) {
|
||||
if (ColorType != SKColorType.Index8)
|
||||
{
|
||||
throw new NotSupportedException(UNSUPPORTED_CLR_TYPE_MSG);
|
||||
}
|
||||
IntPtr length;
|
||||
SetPixels(this.GetPixels(out length), ct);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче