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

Unified Diff: include/core/SkImage.h

Issue 1208993017: Add image->bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months 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 | src/image/SkImage.cpp » ('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 41a1bd85272f163bb5e5a2135ad353ff92cf897b..f623c1f4f378e5dc6fedf2853e7f4d6d9c6f4641 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -264,6 +264,27 @@ public:
SkImage* newImage(int newWidth, int newHeight, const SkIRect* subset = NULL,
SkFilterQuality = kNone_SkFilterQuality) const;
+ // Helper functions to convert to SkBitmap
+
+ enum AsBitmapMode {
+ kRO_AsBitmapMode,
+ kRW_AsBitmapMode,
+ };
+
+ /**
+ * Attempt to create a bitmap with the same pixels as the image.
+ *
+ * If the mode is kRO (read-only), an attempt will be made to share the actual pixel memory,
+ * skipping the cost of a copy. If this can be done, the returned bitmap will be marked
+ * immutable.
+ *
+ * If it cannot, or if the mode is kRW (read-write), then a copy of the pixels will be made.
+ *
robertphillips 2015/07/08 15:41:26 success
reed1 2015/07/08 19:14:43 Done.
+ * On succces, returns true. On failure, returns false and the bitmap parameter will be reset
+ * to empty.
+ */
+ bool asBitmap(SkBitmap*, AsBitmapMode = kRO_AsBitmapMode) const;
+
protected:
SkImage(int width, int height) :
fWidth(width),
« no previous file with comments | « no previous file | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698