Stop using deprecated APIs. Fix by twiz.

http://codereview.appspot.com/4249041/
BUG=http://code.google.com/p/skia/issues/detail?id=151



git-svn-id: http://skia.googlecode.com/svn/trunk@857 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-02-25 15:07:30 +00:00
parent c2a9b7fe56
commit 29f6636a5f

View File

@ -58,7 +58,7 @@ private:
}; };
static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) { static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
SkStream* sk_stream = (SkStream*) png_ptr->io_ptr; SkStream* sk_stream = (SkStream*)png_get_io_ptr(png_ptr);
size_t bytes = sk_stream->read(data, length); size_t bytes = sk_stream->read(data, length);
if (bytes != length) { if (bytes != length) {
png_error(png_ptr, "Read Error!"); png_error(png_ptr, "Read Error!");
@ -201,9 +201,9 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
} }
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
png_set_gray_1_2_4_to_8(png_ptr); png_set_expand_gray_1_2_4_to_8(png_ptr);
} }
/* Make a grayscale image into RGB. */ /* Make a grayscale image into RGB. */
if (color_type == PNG_COLOR_TYPE_GRAY || if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
@ -218,15 +218,19 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
// check for sBIT chunk data, in case we should disable dithering because // check for sBIT chunk data, in case we should disable dithering because
// our data is not truely 8bits per component // our data is not truely 8bits per component
if (doDither) { if (doDither) {
png_color_8p sig_bit = NULL;
bool has_sbit = PNG_INFO_sBIT == png_get_sBIT(png_ptr, info_ptr,
&sig_bit);
#if 0 #if 0
SkDebugf("----- sBIT %d %d %d %d\n", info_ptr->sig_bit.red, if (has_sbit) {
info_ptr->sig_bit.green, info_ptr->sig_bit.blue, SkDebugf("----- sBIT %d %d %d %d\n", sig_bit->red, sig_bit->green,
info_ptr->sig_bit.alpha); sig_bit->blue, sig_bit->alpha);
}
#endif #endif
// 0 seems to indicate no information available // 0 seems to indicate no information available
if (pos_le(info_ptr->sig_bit.red, SK_R16_BITS) && if (has_sbit && pos_le(sig_bit->red, SK_R16_BITS) &&
pos_le(info_ptr->sig_bit.green, SK_G16_BITS) && pos_le(sig_bit->green, SK_G16_BITS) &&
pos_le(info_ptr->sig_bit.blue, SK_B16_BITS)) { pos_le(sig_bit->blue, SK_B16_BITS)) {
doDither = false; doDither = false;
} }
} }
@ -501,7 +505,7 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
#include "SkUnPreMultiply.h" #include "SkUnPreMultiply.h"
static void sk_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) { static void sk_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) {
SkWStream* sk_stream = (SkWStream*)png_ptr->io_ptr; SkWStream* sk_stream = (SkWStream*)png_get_io_ptr(png_ptr);
if (!sk_stream->write(data, len)) { if (!sk_stream->write(data, len)) {
png_error(png_ptr, "sk_write_fn Error!"); png_error(png_ptr, "sk_write_fn Error!");
} }