OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
9 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 return kFailure; | 368 return kFailure; |
369 } | 369 } |
370 | 370 |
371 /* Turn on interlace handling. REQUIRED if you are not using | 371 /* Turn on interlace handling. REQUIRED if you are not using |
372 * png_read_image(). To see how to handle interlacing passes, | 372 * png_read_image(). To see how to handle interlacing passes, |
373 * see the png_read_row() method below: | 373 * see the png_read_row() method below: |
374 */ | 374 */ |
375 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ? | 375 const int number_passes = (interlaceType != PNG_INTERLACE_NONE) ? |
376 png_set_interlace_handling(png_ptr) : 1; | 376 png_set_interlace_handling(png_ptr) : 1; |
377 | 377 |
| 378 if (number_passes > 1) { |
| 379 // For simplified comparison, only do the ones that are not interlaced. |
| 380 return kFailure; |
| 381 } |
| 382 |
378 /* Optional call to gamma correct and add the background to the palette | 383 /* Optional call to gamma correct and add the background to the palette |
379 * and update info structure. REQUIRED if you are expecting libpng to | 384 * and update info structure. REQUIRED if you are expecting libpng to |
380 * update the palette for you (ie you selected such a transform above). | 385 * update the palette for you (ie you selected such a transform above). |
381 */ | 386 */ |
382 png_read_update_info(png_ptr, info_ptr); | 387 png_read_update_info(png_ptr, info_ptr); |
383 | 388 |
384 if ((kAlpha_8_SkColorType == colorType || kIndex_8_SkColorType == colorType)
&& | 389 if ((kAlpha_8_SkColorType == colorType || kIndex_8_SkColorType == colorType)
&& |
385 1 == sampleSize) { | 390 1 == sampleSize) { |
386 if (kAlpha_8_SkColorType == colorType) { | 391 if (kAlpha_8_SkColorType == colorType) { |
387 // For an A8 bitmap, we assume there is an alpha for speed. It is | 392 // For an A8 bitmap, we assume there is an alpha for speed. It is |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 return SkImageDecoder::kUnknown_Format; | 1281 return SkImageDecoder::kUnknown_Format; |
1277 } | 1282 } |
1278 | 1283 |
1279 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1284 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1280 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1285 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1281 } | 1286 } |
1282 | 1287 |
1283 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1288 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1284 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1289 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1285 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1290 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |