diff --git a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp index 0317041ee889..717d872072bd 100644 --- a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp @@ -207,6 +207,11 @@ info_callback(png_structp png_ptr, png_infop info_ptr) png_set_bgr(png_ptr); #endif +#if defined(XP_MAC) || defined(XP_MACOSX) + // MacOS likes pixels padded to word boundaries + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); +#endif + if (png_get_gAMA(png_ptr, info_ptr, &aGamma)) { if (aGamma < 0) aGamma = 0.45455; @@ -301,9 +306,10 @@ info_callback(png_structp png_ptr, png_infop info_ptr) PRUint32 bpr, abpr; decoder->mFrame->GetImageBytesPerRow(&bpr); decoder->mFrame->GetAlphaBytesPerRow(&abpr); - decoder->colorLine = (PRUint8 *)nsMemory::Alloc(bpr); - if (channels > 3) + if (channels > 3) { + decoder->colorLine = (PRUint8 *)nsMemory::Alloc(bpr); decoder->alphaLine = (PRUint8 *)nsMemory::Alloc(abpr); + } if (interlace_type == PNG_INTERLACE_ADAM7) { decoder->interlacebuf = (PRUint8 *)nsMemory::Alloc(channels*width*height); @@ -382,18 +388,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, switch (format) { case gfxIFormats::RGB: case gfxIFormats::BGR: -#if defined(XP_MAC) || defined(XP_MACOSX) - cptr = decoder->colorLine; - for (PRUint32 x=0; xmFrame->SetImageData(decoder->colorLine, bpr, row_num*bpr); -#else - decoder->mFrame->SetImageData((PRUint8*)line, bpr, row_num*bpr); -#endif + decoder->mFrame->SetImageData((PRUint8*)line, bpr, row_num*bpr); break; case gfxIFormats::RGB_A1: case gfxIFormats::BGR_A1: @@ -444,26 +439,6 @@ row_callback(png_structp png_ptr, png_bytep new_row, decoder->mFrame->SetImageData(decoder->colorLine, bpr, row_num*bpr); } break; - case gfxIFormats::RGBA: - case gfxIFormats::BGRA: -#if defined(XP_MAC) || defined(XP_MACOSX) - { - cptr = decoder->colorLine; - aptr = decoder->alphaLine; - for (PRUint32 x=0; xmFrame->SetAlphaData(decoder->alphaLine, abpr, row_num*abpr); - decoder->mFrame->SetImageData(decoder->colorLine, bpr, row_num*bpr); - } -#else - decoder->mFrame->SetImageData(line, bpr, row_num*bpr); -#endif - break; } nsRect r(0, row_num, width, 1);