diff options
-rw-r--r-- | include/core/SkCanvas.h | 58 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 8 |
2 files changed, 33 insertions, 33 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 90bc1f433e..00fdfbee58 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -105,35 +105,35 @@ public: /////////////////////////////////////////////////////////////////////////// - /**
- * On success (returns true), copy the canvas pixels into the bitmap.
- * On failure, the bitmap parameter is left unchanged and false is
- * returned.
- *
- * If the canvas is backed by a non-raster device (e.g. PDF) then
- * readPixels will fail.
- *
- * If the bitmap has pixels already allocated, the canvas pixels will be
- * written there. If not, bitmap->allocPixels() will be called
- * automatically. If the bitmap is backed by a texture readPixels will
- * fail.
- *
- * The canvas' pixels are converted to the bitmap's config. The only
- * supported config is kARGB_8888_Config, though this may be relaxed in
- * future.
- *
- * The actual pixels written is the intersection of the canvas' bounds, and
- * the rectangle formed by the bitmap's width,height and the specified x,y.
- * If bitmap pixels extend outside of that intersection, they will not be
- * modified.
- *
- * Example that reads the entire canvas into a bitmap:
- * SkISize size = canvas->getDeviceSize();
- * bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
- * size.fHeight);
- * if (canvas->readPixels(bitmap, 0, 0)) {
- * // use the pixels
- * }
+ /** + * On success (returns true), copy the canvas pixels into the bitmap. + * On failure, the bitmap parameter is left unchanged and false is + * returned. + * + * If the canvas is backed by a non-raster device (e.g. PDF) then + * readPixels will fail. + * + * If the bitmap has pixels already allocated, the canvas pixels will be + * written there. If not, bitmap->allocPixels() will be called + * automatically. If the bitmap is backed by a texture readPixels will + * fail. + * + * The canvas' pixels are converted to the bitmap's config. The only + * supported config is kARGB_8888_Config, though this may be relaxed in + * future. + * + * The actual pixels written is the intersection of the canvas' bounds, and + * the rectangle formed by the bitmap's width,height and the specified x,y. + * If bitmap pixels extend outside of that intersection, they will not be + * modified. + * + * Example that reads the entire canvas into a bitmap: + * SkISize size = canvas->getDeviceSize(); + * bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, + * size.fHeight); + * if (canvas->readPixels(bitmap, 0, 0)) { + * // use the pixels + * } */ bool readPixels(SkBitmap* bitmap, int x, int y); diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index da7aeb971a..f70795de11 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -560,11 +560,11 @@ bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) { bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { SkDevice* device = this->getDevice(); -
- SkIRect bounds;
+ + SkIRect bounds; bounds.set(0, 0, device->width(), device->height()); - if (!bounds.intersect(srcRect)) {
- return false;
+ if (!bounds.intersect(srcRect)) { + return false; } SkBitmap tmp; |