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???
BITMAPINFOHEADE R bi =(BITMAPINFOHEA DER*)malloc(siz eof(BITMAPINFOH EADER )+256*sizeof(RG BQUAD));
/*BitsPerSample == 8 && SamplePerPixel == 3*/
memset(bi, 0, sizeof(BITMAPIN FOHEADER));
bi->biSize = sizeof(BITMAPIN FOHEADER);
bi->biWidth = imageWidth;
bi->biHeight = imageLength;
bi->biPlanes = 1; // always
bi->biBitCount = 32;
bi->biCompressio n = BI_RGB;
bi->biSizeImage = WIDTHBYTES(bi->biWidth * bi->biBitCount) * bi->biHeight;
bi->biXPelsPerMete r = 0;
bi->biYPelsPerMete r = 0;
bi->biClrUsed = 0; // must be zero for RGB compression (none)
bi->biClrImporta nt = 0; // always
// Get the size of the DIB
dwDIBSize = imageWidth*imag eLength;/*GetDIBSize(& bi );*/
// Allocate for the BITMAPINFO structure and the color table.
/*pDIB = GlobalAllocPtr( GHND, dwDIBSize );*/
HDC dc = CreateCompatibl eDC(pDC->GetSafeHdc() );
hBmp = CreateDIBSectio n(dc, (BITMAPINFO*)bi , DIB_RGB_COLORS,
*((BITMAPINFOHE ADER*)pDIB) = *bi ;
// Get a pointer to the color table
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPIN FOHEADER));
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 in advnace for any valuable advice in this regard pls.
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???
BITMAPINFOHEADE R bi =(BITMAPINFOHEA DER*)malloc(siz eof(BITMAPINFOH EADER )+256*sizeof(RG BQUAD));
/*BitsPerSample == 8 && SamplePerPixel == 3*/
memset(bi, 0, sizeof(BITMAPIN FOHEADER));
bi->biSize = sizeof(BITMAPIN FOHEADER);
bi->biWidth = imageWidth;
bi->biHeight = imageLength;
bi->biPlanes = 1; // always
bi->biBitCount = 32;
bi->biCompressio n = BI_RGB;
bi->biSizeImage = WIDTHBYTES(bi->biWidth * bi->biBitCount) * bi->biHeight;
bi->biXPelsPerMete r = 0;
bi->biYPelsPerMete r = 0;
bi->biClrUsed = 0; // must be zero for RGB compression (none)
bi->biClrImporta nt = 0; // always
// Get the size of the DIB
dwDIBSize = imageWidth*imag eLength;/*GetDIBSize(& bi );*/
// Allocate for the BITMAPINFO structure and the color table.
/*pDIB = GlobalAllocPtr( GHND, dwDIBSize );*/
HDC dc = CreateCompatibl eDC(pDC->GetSafeHdc() );
hBmp = CreateDIBSectio n(dc, (BITMAPINFO*)bi , DIB_RGB_COLORS,
*((BITMAPINFOHE ADER*)pDIB) = *bi ;
// Get a pointer to the color table
RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPIN FOHEADER));
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 in advnace for any valuable advice in this regard pls.