Flutter Engine
The Flutter Engine
Bitmap_pixmap.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Bitmap_pixmap, 256, 256, true, 0) {
5void draw(SkCanvas* canvas) {
7 bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11));
8 SkCanvas offscreen(bitmap);
9 offscreen.clear(SK_ColorWHITE);
11 SkFont font = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
13 offscreen.drawString("&", 0, 10, font, paint);
14 const SkPixmap& pixmap = bitmap.pixmap();
15 if (pixmap.addr()) {
16 SkPMColor pmWhite = *pixmap.addr32(0, 0);
17 for (int y = 0; y < pixmap.height(); ++y) {
18 for (int x = 0; x < pixmap.width(); ++x) {
19 SkDebugf("%c", *pixmap.addr32(x, y) == pmWhite ? '-' : 'x');
20 }
21 SkDebugf("\n");
22 }
23 }
24}
25} // END FIDDLE
REG_FIDDLE(Bitmap_pixmap, 256, 256, true, 0)
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
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
@ 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
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
double y
double x
Definition: bitmap.py:1
font
Font Metadata and Metrics.
static SkImageInfo MakeN32Premul(int width, int height)