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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 int w = readByte(buf, 6 + choice*16); 145 int w = readByte(buf, 6 + choice*16);
146 int h = readByte(buf, 7 + choice*16); 146 int h = readByte(buf, 7 + choice*16);
147 int colorCount = readByte(buf, 8 + choice*16); 147 int colorCount = readByte(buf, 8 + choice*16);
148 //int reservedToo = readByte(buf, 9 + choice*16); //0 148 //int reservedToo = readByte(buf, 9 + choice*16); //0
149 //int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0 149 //int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0
150 //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usu ally 0 150 //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usu ally 0
151 int size = read4Bytes(buf, 14 + choice*16); //matters? 151 int size = read4Bytes(buf, 14 + choice*16); //matters?
152 int offset = read4Bytes(buf, 18 + choice*16); 152 int offset = read4Bytes(buf, 18 + choice*16);
153 if ((size_t)(offset + size) > length) 153 if ((size_t)(offset + size) > length)
154 return false; 154 return false;
155
156 // Check to see if this is a PNG image inside the ICO
157 {
158 SkMemoryStream subStream(buf + offset, size, false);
159 SkAutoTDelete<SkImageDecoder> otherDecoder(SkImageDecoder::Factory(&subS tream));
160 if (otherDecoder.get() != NULL) {
161 // Set fields on the other decoder to be the same as this one.
162 this->copyFieldsToOther(otherDecoder.get());
163 if(otherDecoder->decode(&subStream, bm, this->getDefaultPref(), mode )) {
164 return true;
165 }
166 }
167 }
168
155 //int infoSize = read4Bytes(buf, offset); //40 169 //int infoSize = read4Bytes(buf, offset); //40
156 //int width = read4Bytes(buf, offset+4); //should == w 170 //int width = read4Bytes(buf, offset+4); //should == w
157 //int height = read4Bytes(buf, offset+8); //should == 2*h 171 //int height = read4Bytes(buf, offset+8); //should == 2*h
158 //int planesToo = read2Bytes(buf, offset+12); //should == 1 (does it ?) 172 //int planesToo = read2Bytes(buf, offset+12); //should == 1 (does it ?)
159 int bitCount = read2Bytes(buf, offset+14); 173 int bitCount = read2Bytes(buf, offset+14);
160 174
161 void (*placePixel)(const int pixelNo, const unsigned char* buf, 175 void (*placePixel)(const int pixelNo, const unsigned char* buf,
162 const int xorOffset, int& x, int y, const int w, 176 const int xorOffset, int& x, int y, const int w,
163 SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors) = NULL ; 177 SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors) = NULL ;
164 switch (bitCount) 178 switch (bitCount)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory); 414 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory);
401 415
402 static SkImageDecoder::Format get_format_ico(SkStream* stream) { 416 static SkImageDecoder::Format get_format_ico(SkStream* stream) {
403 if (is_ico(stream)) { 417 if (is_ico(stream)) {
404 return SkImageDecoder::kICO_Format; 418 return SkImageDecoder::kICO_Format;
405 } 419 }
406 return SkImageDecoder::kUnknown_Format; 420 return SkImageDecoder::kUnknown_Format;
407 } 421 }
408 422
409 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_ico) ; 423 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_ico) ;
OLDNEW
« 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