diff --git a/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp index 091c2dca1d1..c5616a2c1ea 100644 --- a/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp @@ -49,6 +49,7 @@ #include "ImageLogging.h" #include "nsIImage.h" #include "nsIInterfaceRequestorUtils.h" +#include "gfxColor.h" #include "jerror.h" @@ -470,7 +471,6 @@ nsJPEGDecoder::OutputScanlines() PRUint8 *imageData; PRUint32 imageDataLength; mFrame->GetImageData(&imageData, &imageDataLength); - nsCOMPtr img(do_GetInterface(mFrame)); while ((mInfo.output_scanline < mInfo.output_height)) { /* Request one scanline. Returns 0 or 1 scanlines. */ @@ -483,16 +483,15 @@ nsJPEGDecoder::OutputScanlines() PRUint32 offset = (mInfo.output_scanline - 1) * mInfo.output_width; PRUint32 *ptrOutputBuf = ((PRUint32*)imageData) + offset; JSAMPLE *j1 = mSamples[0]; - for (PRUint32 i=0; i < mInfo.output_width; ++i) { - PRUint8 r = *j1++; - PRUint8 g = *j1++; - PRUint8 b = *j1++; - *ptrOutputBuf++ = (0xFF << 24) | (r << 16) | (g << 8) | b; + for (PRUint32 i=mInfo.output_width; i>0; --i) { + *ptrOutputBuf++ = GFX_PACKED_PIXEL(0xFF, j1[0], j1[1], j1[2]); + j1+=3; } } if (top != mInfo.output_scanline) { nsIntRect r(0, top, mInfo.output_width, mInfo.output_scanline-top); + nsCOMPtr img(do_GetInterface(mFrame)); img->ImageUpdated(nsnull, nsImageUpdateFlags_kBitsChanged, &r); mObserver->OnDataAvailable(nsnull, mFrame, &r); }