Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
copy_to_4444.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "tools/DecodeUtils.h"
#include "tools/Resources.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (format4444, canvas, 64, 64)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( format4444  ,
canvas  ,
64  ,
64   
)

Definition at line 51 of file copy_to_4444.cpp.

51 {
52 canvas->scale(16, 16);
55 bitmap.allocPixels(imageInfo);
56 SkCanvas offscreen(bitmap);
57 offscreen.clear(SK_ColorRED);
58 canvas->drawImage(bitmap.asImage(), 0, 0);
59 offscreen.clear(SK_ColorBLUE);
60 canvas->drawImage(bitmap.asImage(), 1, 1);
61 auto pack4444 = [](unsigned a, unsigned r, unsigned g, unsigned b) -> uint16_t {
62 return (a << 0) | (b << 4) | (g << 8) | (r << 12);
63 };
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)) {
68 canvas->drawImage(bitmap.asImage(), 2, 2);
69 }
70 SkPixmap bluePixmap(imageInfo, &blue4444, 2);
71 if (bitmap.writePixels(bluePixmap, 0, 0)) {
72 canvas->drawImage(bitmap.asImage(), 3, 3);
73 }
74}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
static bool b
struct MyStruct a[10]
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)