SK_API bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, size_t rowBytes);
SK_API bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, sk_pixelref_factory_t* factory, sk_colortable_t* ctable);
SK_API sk_colortable_t* sk_bitmap_get_colortable(sk_bitmap_t* cbitmap);
+SK_API void sk_bitmap_set_colortable(sk_bitmap_t* cbitmap, sk_colortable_t* ctable);
SK_C_PLUS_PLUS_END_GUARD
}
}
+static inline void copyIndex8ToColor(sk_bitmap_t* cbitmap, size_t size, const uint8_t* pixels, sk_color_t* colors)
+{
+ SkBitmap* bmp = AsBitmap(cbitmap);
+ SkColorTable* ctable = bmp->getColorTable();
+ while (size-- != 0) {
+ const uint8_t* addr = pixels++;
+ const SkPMColor c = (*ctable)[*addr];
+ *colors++ = SkUnPreMultiply::PMColorToColor(c);
+ }
+}
+
static inline void copyGray8ToColor(size_t size, const uint8_t* pixels, sk_color_t* colors)
{
while (size-- != 0) {
case kAlpha_8_SkColorType:
copyAlpha8ToColor(size, (const uint8_t*)pixels, colors);
break;
+ case kIndex_8_SkColorType:
+ copyIndex8ToColor(cbitmap, size, (const uint8_t*)pixels, colors);
+ break;
case kGray_8_SkColorType:
copyGray8ToColor(size, (const uint8_t*)pixels, colors);
break;
{
return ToColorTable(AsBitmap(cbitmap)->getColorTable());
}
+
+void sk_bitmap_set_colortable(sk_bitmap_t* cbitmap, sk_colortable_t* ctable)
+{
+ SkBitmap* bmp AsBitmap(cbitmap);
+ bmp->setPixels(bmp->getPixels(), AsColorTable(ctable));
+}
\ No newline at end of file