Bug 723453 - Split cases for ConvertHostARGB - r=joe

This commit is contained in:
Jeff Gilbert 2012-02-10 15:41:24 -08:00
parent bb747061d8
commit 98033e03ef

View File

@ -437,17 +437,26 @@ void
nsBMPEncoder::ConvertHostARGBRow(const PRUint8* aSrc, PRUint8* aDest,
PRUint32 aPixelWidth)
{
for (PRUint32 x = 0; x < aPixelWidth; x ++) {
const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
PRUint8 *pixelOut = &aDest[x * BytesPerPixel(mBMPInfoHeader.bpp)];
int bytes = BytesPerPixel(mBMPInfoHeader.bpp);
PRUint8 alpha = (pixelIn & 0xff000000) >> 24;
pixelOut[0] = (((pixelIn & 0xff0000) >> 16));
pixelOut[1] = (((pixelIn & 0x00ff00) >> 8));
pixelOut[2] = (((pixelIn & 0x0000ff) >> 0));
if (mBMPInfoHeader.bpp == 32) {
for (PRUint32 x = 0; x < aPixelWidth; x++) {
const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
PRUint8 *pixelOut = &aDest[x * bytes];
if (mBMPInfoHeader.bpp == 32) {
pixelOut[3] = alpha;
pixelOut[0] = (pixelIn & 0x00ff0000) >> 16;
pixelOut[1] = (pixelIn & 0x0000ff00) >> 8;
pixelOut[2] = (pixelIn & 0x000000ff) >> 0;
pixelOut[3] = (pixelIn & 0xff000000) >> 24;
}
} else {
for (PRUint32 x = 0; x < aPixelWidth; x++) {
const PRUint32& pixelIn = ((const PRUint32*)(aSrc))[x];
PRUint8 *pixelOut = &aDest[x * bytes];
pixelOut[0] = (pixelIn & 0xff0000) >> 16;
pixelOut[1] = (pixelIn & 0x00ff00) >> 8;
pixelOut[2] = (pixelIn & 0x0000ff) >> 0;
}
}
}