34 *errorMsg =
"Could not decode the file. Did you forget to set the resourcePath?";
47DEF_GM(
return new CopyTo4444GM; )
52 canvas->
scale(16, 16);
55 bitmap.allocPixels(imageInfo);
61 auto pack4444 = [](
unsigned a,
unsigned r,
unsigned g,
unsigned b) -> uint16_t {
62 return (
a << 0) | (
b << 4) | (g << 8) | (r << 12);
64 uint16_t red4444 = pack4444(0xF, 0xF, 0x0, 0x0);
65 uint16_t blue4444 = pack4444(0xF, 0x0, 0x0, 0x0F);
66 SkPixmap redPixmap(imageInfo, &red4444, 2);
67 if (
bitmap.writePixels(redPixmap, 0, 0)) {
70 SkPixmap bluePixmap(imageInfo, &blue4444, 2);
71 if (
bitmap.writePixels(bluePixmap, 0, 0)) {
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
sk_sp< SkImage > asImage() const
void clear(SkColor color)
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
virtual SkISize getISize()=0
virtual SkString getName() const =0
virtual DrawResult onDraw(SkCanvas *, SkString *errorMsg)
DEF_SIMPLE_GM(format4444, canvas, 64, 64)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)