aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images/SkImageDecoder_libpng.cpp
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-04-28 15:27:07 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-04-28 15:27:07 +0000
commit862e91be0225be1e5cfc8157301cfc13d8da4287 (patch)
treeb57e725318a31cb68656ba375584a430d10ac946 /src/images/SkImageDecoder_libpng.cpp
parentaf459795e393dabd8ea02afade5609935c0d9509 (diff)
handle interlacing
git-svn-id: http://skia.googlecode.com/svn/trunk@161 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/images/SkImageDecoder_libpng.cpp')
-rw-r--r--src/images/SkImageDecoder_libpng.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index b616eee918..1d1dd34433 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -387,15 +387,32 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
} else {
sc = SkScaledBitmapSampler::kRGBX;
}
-
- SkAutoMalloc storage(origWidth * srcBytesPerPixel);
+ if (!sampler.begin(decodedBitmap, sc, doDither)) {
+ return false;
+ }
const int height = decodedBitmap->height();
- for (int i = 0; i < number_passes; i++) {
- if (!sampler.begin(decodedBitmap, sc, doDither)) {
- return false;
+ if (number_passes > 1) {
+ SkAutoMalloc storage(origWidth * origHeight * srcBytesPerPixel);
+ uint8_t* base = (uint8_t*)storage.get();
+ size_t rb = origWidth * srcBytesPerPixel;
+
+ for (int i = 0; i < number_passes; i++) {
+ uint8_t* row = base;
+ for (png_uint_32 y = 0; y < origHeight; y++) {
+ uint8_t* bmRow = row;
+ png_read_rows(png_ptr, &bmRow, png_bytepp_NULL, 1);
+ row += rb;
+ }
}
-
+ // now sample it
+ base += sampler.srcY0() * rb;
+ for (int y = 0; y < height; y++) {
+ reallyHasAlpha |= sampler.next(base);
+ base += sampler.srcDY() * rb;
+ }
+ } else {
+ SkAutoMalloc storage(origWidth * srcBytesPerPixel);
uint8_t* srcRow = (uint8_t*)storage.get();
skip_src_rows(png_ptr, srcRow, sampler.srcY0());
@@ -407,20 +424,13 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
skip_src_rows(png_ptr, srcRow, sampler.srcDY() - 1);
}
}
-
+
// skip the rest of the rows (if any)
png_uint_32 read = (height - 1) * sampler.srcDY() +
sampler.srcY0() + 1;
SkASSERT(read <= origHeight);
skip_src_rows(png_ptr, srcRow, origHeight - read);
}
-
- if (hasAlpha && !reallyHasAlpha) {
-#if 0
- SkDEBUGF(("Image doesn't really have alpha [%d %d]\n",
- origWidth, origHeight));
-#endif
- }
}
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */