From 0c5f54663b3080819825bd035979a82d4c5ac902 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 15 Dec 2017 11:21:51 -0500 Subject: working on image docs some new image work turn dos into unix linefeeds add SkBitmap::pixmap() Docs-Preview: https://skia.org/?cl=83863 TBR=caryclark@google.com Bug: skia:6898 Change-Id: I06242b4b66464814b753fe37f930baf32f79323a Reviewed-on: https://skia-review.googlesource.com/83863 Reviewed-by: Cary Clark Commit-Queue: Cary Clark --- docs/SkBitmap_Reference.bmh | 53 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'docs/SkBitmap_Reference.bmh') diff --git a/docs/SkBitmap_Reference.bmh b/docs/SkBitmap_Reference.bmh index 4e0525e85f..6608876937 100644 --- a/docs/SkBitmap_Reference.bmh +++ b/docs/SkBitmap_Reference.bmh @@ -122,6 +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. ## # readPixels # Copies and converts pixels. ## # readyToDraw # Returns true if address of pixels is not nullptr. ## # refColorSpace # Returns Image_Info Color_Space. ## @@ -447,6 +448,56 @@ two width:1 height:1 colorType:kRGBA_8888_SkColorType alphaType:kOpaque_SkAlphaT # ------------------------------------------------------------------------------ +#Method 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. + +Returned Pixmap becomes invalid on any future change to Bitmap + +#Return Pixmap describing Bitmap, if pixels are readable; otherwise containing zeroes ## + +#Example + SkBitmap bitmap; + bitmap.allocPixels(SkImageInfo::MakeN32Premul(10, 11)); + SkCanvas offscreen(bitmap); + offscreen.clear(SK_ColorWHITE); + SkPaint paint; + offscreen.drawString("&", 0, 10, paint); + 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'); + } + SkDebugf("\n"); + } + } + #StdOut +---------- +---xx----- +--x--x---- +--x------- +--xx------ +--x-x---x- +-x---x--x- +-x----xx-- +-xx---x--- +--xxxx-xx- +---------- + #StdOut ## + +## + +#SeeAlso peekPixels installPixels readPixels writePixels + +## + +# ------------------------------------------------------------------------------ + #Method const SkImageInfo& info() const Returns width, height, Alpha_Type, Color_Type, and Color_Space. @@ -3401,7 +3452,7 @@ x---x- #StdOut ## ## -#SeeAlso installPixels readPixels writePixels +#SeeAlso pixmap() installPixels readPixels writePixels ## -- cgit v1.2.3