Click to See Complete Forum and Search --> : 8,9,12,16bit to 24bit DIB


Brooks Younce
August 24th, 2005, 03:26 PM
I am looking for a method to convert 8,9,12,15,16bit DIB images to a 24bit DIB image so I can use the Standard JpegFile class to save these bitmap types.
I found a 32bit to 24bit function (shown below) but how can I make a lower resolution image into a 24bit DIB ??

I have not found a jpeg class that allows saving anything but a 24bit DIB.


//p32Img is our 32bit DIB, p24Img is our 24bit Output DIB
BOOL CDXVideo::Convert24Image(BYTE *p32Img, BYTE *p24Img,DWORD dwSize32)
{
if(p32Img != NULL && p24Img != NULL && dwSize32 > 0 && dwSize32 < INT_MAX)
{

DWORD dwSize24 = (dwSize32 * 3)/4;

BYTE *pTemp,*ptr;

//pTemp = p32Img;
pTemp = p32Img + sizeof(BITMAPINFOHEADER);
ptr = p24Img + dwSize24-1 ;

int ival=0;
for (DWORD index = 0; index < dwSize32/4 ; index++)
{
unsigned char r = *(pTemp++);
unsigned char g = *(pTemp++);
unsigned char b = *(pTemp++);
(pTemp++);//skip alpha

*(ptr--) = b;
*(ptr--) = g;
*(ptr--) = r;
}
}
else
{
return FALSE;
}

return TRUE;
}

golanshahar
August 25th, 2005, 01:08 AM
read this Thread (http://www.codeguru.com/forum/showthread.php?t=349228) might help you.

Cheers

Marc G
August 25th, 2005, 12:24 PM
[ moved thread ]