Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
Bitmap_pixmap.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Bitmap_pixmap, 256, 256, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Bitmap_pixmap  ,
256  ,
256  ,
true  ,
 
)

Definition at line 5 of file Bitmap_pixmap.cpp.

5 {
6void draw(SkCanvas* canvas) {
8 bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11));
9 SkCanvas offscreen(bitmap);
10 offscreen.clear(SK_ColorWHITE);
12 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
14 offscreen.drawString("&", 0, 10, font, paint);
15 const SkPixmap& pixmap = bitmap.pixmap();
16 if (pixmap.addr()) {
17 SkPMColor pmWhite = *pixmap.addr32(0, 0);
18 for (int y = 0; y < pixmap.height(); ++y) {
19 for (int x = 0; x < pixmap.width(); ++x) {
20 SkDebugf("%c", *pixmap.addr32(x, y) == pmWhite ? '-' : 'x');
21 }
22 SkDebugf("\n");
23 }
24 }
25}
26} // END FIDDLE
uint32_t SkPMColor
Definition SkColor.h:205
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
@ kAlias
no transparent pixels on glyph edges
const uint32_t * addr32() const
Definition SkPixmap.h:352
int width() const
Definition SkPixmap.h:160
const void * addr() const
Definition SkPixmap.h:153
int height() const
Definition SkPixmap.h:166
const Paint & paint
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
double y
double x
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)