Load image in CMYK format to DIB

Hi All,


Is there any method to load DIB with CMYK image format. I am using the following method to store image pixel to DIB. In this case raster image in the RGBA format is used. We cannot store CMYK pixel. Is there any method for actual CMYK pixel images than this given below???

BITMAPINFOHEADER bi =(BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER )+256*sizeof(RGBQUAD));

/*BitsPerSample == 8 && SamplePerPixel == 3*/

memset(bi, 0, sizeof(BITMAPINFOHEADER));

bi->biSize = sizeof(BITMAPINFOHEADER);
bi->biWidth = imageWidth;
bi->biHeight = imageLength;
bi->biPlanes = 1; // always
bi->biBitCount = 32;
bi->biCompression = BI_RGB;
bi->biSizeImage = WIDTHBYTES(bi->biWidth * bi->biBitCount) * bi->biHeight;
bi->biXPelsPerMeter = 0;
bi->biYPelsPerMeter = 0;
bi->biClrUsed = 0; // must be zero for RGB compression (none)
bi->biClrImportant = 0; // always

// Get the size of the DIB
dwDIBSize = imageWidth*imageLength;/*GetDIBSize(& bi );*/

// Allocate for the BITMAPINFO structure and the color table.
/*pDIB = GlobalAllocPtr( GHND, dwDIBSize );*/
HDC dc = CreateCompatibleDC(pDC->GetSafeHdc());
hBmp = CreateDIBSection(dc, (BITMAPINFO*)bi, DIB_RGB_COLORS,


*((BITMAPINFOHEADER*)pDIB) = *bi ;

// Get a pointer to the color table
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER));


int sizeWords = bi->biSizeImage/4;
RGBQUAD* rgbDib = (RGBQUAD*)pDIB;

LPRGBQUAD lpr = (LPRGBQUAD)pDIB;

long* rgbTif = (long*)raster;

// Swap the byte order while copying
for ( int i = 0 ; i < sizeWords ; ++i )
{
rgbDib[i].rgbRed = TIFFGetR(rgbTif[i]);
rgbDib[i].rgbBlue = TIFFGetB(rgbTif[i]);
rgbDib[i].rgbGreen = TIFFGetG(rgbTif[i]);
rgbDib[i].rgbReserved = 0;
}


Thanks for any valuable advice in this regard.
Use GDI +
Topic archived. No new replies allowed.