Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: include/core/SkImage.h

Issue 793723002: add readPixels to SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use better name on test Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkSurface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImage.h
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 63fa41b4e7953a4448b4abf40bd58d10704a2b61..6070b6bf6bfefdd50ba5bc07ca8e118f54ef9165 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -85,6 +85,27 @@ public:
const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const;
/**
+ * Copy the pixels from the image into the specified buffer (pixels + rowBytes),
+ * converting them into the requested format (dstInfo). The image pixels are read
+ * starting at the specified (srcX,srcY) location.
+ *
+ * The specified ImageInfo and (srcX,srcY) offset specifies a source rectangle
+ *
+ * srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height());
+ *
+ * srcR is intersected with the bounds of the image. 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 image bounds.
+ * - If the requested colortype/alphatype cannot be converted from the image's types.
+ */
+ bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
+ int srcX, int srcY) const;
+
+ /**
* Encode the image's pixels and return the result as a new SkData, which
* the caller must manage (i.e. call unref() when they are done).
*
@@ -134,29 +155,6 @@ private:
* See SkCanvas::drawBitmapRectToRect for similar behavior.
*/
void drawRect(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*) const;
-
- /**
- * Return a copy of the image's pixels, limiting them to the subset
- * rectangle's intersection wit the image bounds. If subset is NULL, then
- * the entire image will be considered.
- *
- * If the bitmap's pixels have already been allocated, then readPixels()
- * will succeed only if it can support converting the image's pixels into
- * the bitmap's ColorType/AlphaType. Any pixels in the bitmap that do not
- * intersect with the image's bounds and the subset (if not null) will be
- * left untouched.
- *
- * If the bitmap is initially empty/unallocated, then it will be allocated
- * using the default allocator, and the ColorType/AlphaType will be chosen
- * to most closely fit the image's configuration.
- *
- * On failure, false will be returned, and bitmap will unmodified.
- */
- // On ice for now:
- // - should it respect the particular colortype/alphatype of the src
- // - should it have separate entrypoints for preallocated and not bitmaps?
- // - isn't it enough to allow the caller to draw() the image into a canvas?
- bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const;
};
#endif
« no previous file with comments | « no previous file | include/core/SkSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698