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

Unified Diff: src/images/SkImageDecoder_libico.cpp

Issue 18655007: Allow ico decoder to decode PNG sub-images. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | « src/images/SkImageDecoder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libico.cpp
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index 195b6ff08b9338ee4c4502b4efb6f5b5a2c31785..04978b00c19333b8b37ed3c3eda0248086f68605 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -152,6 +152,20 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
int offset = read4Bytes(buf, 18 + choice*16);
if ((size_t)(offset + size) > length)
return false;
+
+ // Check to see if this is a PNG image inside the ICO
+ {
+ SkMemoryStream subStream(buf + offset, size, false);
+ SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subStream));
+ if (otherDecoder.get() != NULL) {
+ // Set fields on the other decoder to be the same as this one.
+ this->copyFieldsToOther(otherDecoder.get());
+ if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode)) {
+ return true;
+ }
+ }
+ }
+
//int infoSize = read4Bytes(buf, offset); //40
//int width = read4Bytes(buf, offset+4); //should == w
//int height = read4Bytes(buf, offset+8); //should == 2*h
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698