473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 in advnace for any valuable advice in this regard pls.
Feb 1 '10 #1
0 1612

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rune Johansen | last post by:
Hi. I'm doing some image manipulation in an applet using the example code on this page: http://www.akop.org/art/pixels3.htm However, I really want an application rather than an applet, I just...
4
by: Johan Holst Nielsen | last post by:
Hi all, I hope someone can help me. I have do do a color conversion from RGB to CMYK. It's harder than I thought :D Anyway, here is my problem. I tried some differents ways to do it - I...
7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
3
by: Steve Tooke | last post by:
I'm trying to find a way to quickly read image headers (specifically jpgs at the moment) with out loading the whole image as an System.Imaging.Image. Anybody point me in the right direction or am I...
1
by: Dennis Myrén | last post by:
Hi. I have already posted this question once, but this repost is to ensure no gurus missed it, who might be able to help me out here; I would like to know whether it is possible - without...
0
by: Digit24 | last post by:
Is there any way to convert a cmyk image to rgb automatically through asp.net? Spent ages searching Google with not much success!
3
by: James | last post by:
Need help to convert a RGB (jpg) image to CMYK colors... Is it possible to convert i using GDI+? Can someone please give me som guide lines. Thanks for you help and time. Best Regards...
7
by: Ben | last post by:
Hi We are looking for a component that offers that offers the below for Tiff files: Image clean-up (deskew, despeckle) Printing capabilities from VB The ability to add text to image, e.g....
1
by: Freedolen | last post by:
Hi, Iam new to this forum. I need to find the given TIFF image is in CMYK or RGB. Though i have checked with Image::Magick, and used: my $img = new Image::Magick; $img->Read("Sample.tif");...
4
by: anthony | last post by:
Images stored in our database (stored as filenames but held elsewhere) will form part of a long report. It is critical that when the report prints the images appear at the highest possible quality...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.