OLD | NEW |
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, | 303 bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap, |
304 Mode mode) { | 304 Mode mode) { |
305 png_structp png_ptr; | 305 png_structp png_ptr; |
306 png_infop info_ptr; | 306 png_infop info_ptr; |
307 | 307 |
308 if (!onDecodeInit(sk_stream, &png_ptr, &info_ptr)) { | 308 if (!onDecodeInit(sk_stream, &png_ptr, &info_ptr)) { |
309 return false; | 309 return false; |
310 } | 310 } |
311 | 311 |
| 312 PNGAutoClean autoClean(png_ptr, info_ptr); |
| 313 |
312 if (setjmp(png_jmpbuf(png_ptr))) { | 314 if (setjmp(png_jmpbuf(png_ptr))) { |
313 return false; | 315 return false; |
314 } | 316 } |
315 | 317 |
316 PNGAutoClean autoClean(png_ptr, info_ptr); | |
317 | |
318 png_uint_32 origWidth, origHeight; | 318 png_uint_32 origWidth, origHeight; |
319 int bitDepth, colorType, interlaceType; | 319 int bitDepth, colorType, interlaceType; |
320 png_get_IHDR(png_ptr, info_ptr, &origWidth, &origHeight, &bitDepth, | 320 png_get_IHDR(png_ptr, info_ptr, &origWidth, &origHeight, &bitDepth, |
321 &colorType, &interlaceType, int_p_NULL, int_p_NULL); | 321 &colorType, &interlaceType, int_p_NULL, int_p_NULL); |
322 | 322 |
323 SkBitmap::Config config; | 323 SkBitmap::Config config; |
324 bool hasAlpha = false; | 324 bool hasAlpha = false; |
325 SkPMColor theTranspColor = 0; // 0 tells us not to try to match | 325 SkPMColor theTranspColor = 0; // 0 tells us not to try to match |
326 | 326 |
327 if (!this->getBitmapConfig(png_ptr, info_ptr, &config, &hasAlpha, &theTransp
Color)) { | 327 if (!this->getBitmapConfig(png_ptr, info_ptr, &config, &hasAlpha, &theTransp
Color)) { |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 return SkImageDecoder::kUnknown_Format; | 1291 return SkImageDecoder::kUnknown_Format; |
1292 } | 1292 } |
1293 | 1293 |
1294 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1294 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1295 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1295 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1296 } | 1296 } |
1297 | 1297 |
1298 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1298 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1299 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1299 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1300 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1300 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |