diff options
Diffstat (limited to 'docs/SkBitmap_Reference.bmh')
-rw-r--r-- | docs/SkBitmap_Reference.bmh | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh index 94a993ce89..5eba984ebb 100644 --- a/docs/SkBitmap_Reference.bmh +++ b/docs/SkBitmap_Reference.bmh @@ -122,7 +122,7 @@ is useful to position one or more Bitmaps within a shared pixel array. # peekPixels # Returns Pixmap if possible. ## # pixelRef # Returns Pixel_Ref, or nullptr. ## # pixelRefOrigin # Returns offset within Pixel_Ref. ## -# pixmap() # Returns Pixmap if possible. ## +# pixmap() # Returns Pixmap. ## # readPixels # Copies and converts pixels. ## # readyToDraw # Returns true if address of pixels is not nullptr. ## # refColorSpace # Returns Image_Info Color_Space. ## @@ -448,16 +448,12 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT # ------------------------------------------------------------------------------ -#Method SkPixmap pixmap() const +#Method const SkPixmap& pixmap() const -Returns Pixmap with Bitmap pixel address, row bytes, and Image_Info, if address -is available. If pixel address is not available, returns default constructed -Pixmap: nullptr pixels, kUnknown_SkColorType, kUnknown_SkAlphaType, width and -height of zero. +Returns a constant reference to the Pixmap holding the Bitmap pixel +address, row bytes, and Image_Info. -Returned Pixmap becomes invalid on any future change to Bitmap - -#Return Pixmap describing Bitmap, if pixels are readable; otherwise containing zeroes ## +#Return reference to Pixmap describing this Bitmap. ## #Example SkBitmap bitmap; @@ -466,13 +462,12 @@ Returned Pixmap becomes invalid on any future change to Bitmap offscreen.clear(SK_ColorWHITE); SkPaint paint; offscreen.drawString("&", 0, 10, paint); - SkPixmap pixmap = bitmap.pixmap(); + const SkPixmap& pixmap = bitmap.pixmap(); if (pixmap.addr()) { - const SkPMColor* pixels = pixmap.addr32(); - SkPMColor pmWhite = pixels[0]; - for (int y = 0; y < bitmap.height(); ++y) { - for (int x = 0; x < bitmap.width(); ++x) { - SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x'); + SkPMColor pmWhite = *pixmap.addr32(0, 0); + for (int y = 0; y < pixmap.height(); ++y) { + for (int x = 0; x < pixmap.width(); ++x) { + SkDebugf("%c", *pixmap.addr32(x, y) == pmWhite ? '-' : 'x'); } SkDebugf("\n"); } |