diff options
author | 2014-07-12 12:26:36 -0700 | |
---|---|---|
committer | 2014-07-12 12:26:36 -0700 | |
commit | debba5c3d091159149f8a88ab5dcd44dd72e0dc7 (patch) | |
tree | 2ccf7f439aba044eabaaa43739dba23e544586c9 /include/core/SkCanvas.h | |
parent | fb747e2c745896dd94425ff690483ae3838e88fe (diff) |
Add SkBitmap::readPixels() and reimplement copyTo and SkCanvas::readPixels
usning it.
Revert "Revert of add readPixels() to SkBitmap (https://codereview.chromium.org/377303002/)"
This reverts commit d08cb905a7cc80d8fb868bbd14fffe1cd68adcce.
R=reed@chromium.org
TBR=scroggo@google.com
Author: reed@google.com
Review URL: https://codereview.chromium.org/388803007
Diffstat (limited to 'include/core/SkCanvas.h')
-rw-r--r-- | include/core/SkCanvas.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 424c12dbf3..6bd3cc5363 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -234,30 +234,31 @@ public: /** * Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes), * converting them into the requested format (SkImageInfo). The base-layer pixels are read - * starting at the specified (x,y) location in the coordinate system of the base-layer. + * starting at the specified (srcX,srcY) location in the coordinate system of the base-layer. * - * The specified ImageInfo and (x,y) offset specifies a source rectangle + * The specified ImageInfo and (srcX,srcY) offset specifies a source rectangle * - * srcR(x, y, info.width(), info.height()); + * srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height()); * - * SrcR is intersected with the bounds of the base-layer. If this intersection is not empty, - * then we have two sets of pixels (of equal size), the "src" specified by base-layer at (x,y) - * and the "dst" by info+pixels+rowBytes. Replace the dst pixels with the corresponding src - * pixels, performing any colortype/alphatype transformations needed (in the case where the - * src and dst have different colortypes or alphatypes). + * srcR is intersected with the bounds of the base-layer. If this intersection is not empty, + * then we have two sets of pixels (of equal size). Replace the dst pixels with the + * corresponding src pixels, performing any colortype/alphatype transformations needed + * (in the case where the src and dst have different colortypes or alphatypes). * * This call can fail, returning false, for several reasons: + * - If srcR does not intersect the base-layer bounds. * - If the requested colortype/alphatype cannot be converted from the base-layer's types. * - If this canvas is not backed by pixels (e.g. picture or PDF) */ - bool readPixels(const SkImageInfo&, void* pixels, size_t rowBytes, int x, int y); + bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, + int srcX, int srcY); /** * Helper for calling readPixels(info, ...). This call will check if bitmap has been allocated. * If not, it will attempt to call allocPixels(). If this fails, it will return false. If not, * it calls through to readPixels(info, ...) and returns its result. */ - bool readPixels(SkBitmap* bitmap, int x, int y); + bool readPixels(SkBitmap* bitmap, int srcX, int srcY); /** * Helper for allocating pixels and then calling readPixels(info, ...). The bitmap is resized |