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

Unified Diff: src/core/SkBitmap.cpp

Issue 108663004: make info real in SkPixelRef, and add bitmap::asImageInfo (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | « include/core/SkPixelRef.h ('k') | src/image/SkImagePriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 7e204f22d33811fd729815881bbf88352492a638..25a6b1dba44790ce0bee01bb22f4b92bfd54c426 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -361,6 +361,48 @@ void SkBitmap::updatePixelsFromRef() const {
}
}
+static bool config_to_colorType(SkBitmap::Config config, SkColorType* ctOut) {
+ SkColorType ct;
+ switch (config) {
+ case SkBitmap::kA8_Config:
+ ct = kAlpha_8_SkColorType;
+ break;
+ case SkBitmap::kIndex8_Config:
+ ct = kIndex_8_SkColorType;
+ break;
+ case SkBitmap::kRGB_565_Config:
+ ct = kRGB_565_SkColorType;
+ break;
+ case SkBitmap::kARGB_4444_Config:
+ ct = kARGB_4444_SkColorType;
+ break;
+ case SkBitmap::kARGB_8888_Config:
+ ct = kPMColor_SkColorType;
+ break;
+ case SkBitmap::kNo_Config:
+ default:
+ return false;
+ }
+ if (ctOut) {
+ *ctOut = ct;
+ }
+ return true;
+}
+
+bool SkBitmap::asImageInfo(SkImageInfo* info) const {
+ SkColorType ct;
+ if (!config_to_colorType(this->config(), &ct)) {
+ return false;
+ }
+ if (info) {
+ info->fWidth = fWidth;
+ info->fHeight = fHeight;
+ info->fAlphaType = this->alphaType();
+ info->fColorType = ct;
+ }
+ return true;
+}
+
SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) {
// do this first, we that we never have a non-zero offset with a null ref
if (NULL == pr) {
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/image/SkImagePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698