Re: [Lcms-user] Idiots guide to CMYK->RGB conversions
An ICC-based CMM for color management
Brought to you by:
mm2
From: <ma...@li...> - 2001-08-29 08:27:12
|
Hi,=20 You almost got it... just replace TYPE_CMYK_16 with TYPE_CMYK_8, and = SHORT with BYTE,=20 and your program will work. The buffers are supposed to be arrays of values, since images are stored = in such way, the number at end of descriptor (e.g. TYPE_RGB_*) is the number of bits = per component.=20 TYPE_RGB_8 is 8 bits, so r, g and b are regarded to be BYTEs. = TYPE_RGB_16 is 16 bits,=20 then r, g, b are WORDs (this is for dealing with 16 bps images, not very = common). There are=20 many descriptors, lcms can undestand a lot of layouts. As said, this = works in such way=20 because scanlines of images are stored as arrays of values. If you want to convert, say, 300 pixels at time, you will need 300 = pixels x 3 components =3D=20 900 bytes, so you can use output buffer of 900 bytes; BYTE OutputBuffer[900]; In CMYK there are 4 components, so 300 x 4 =3D 1200 bytes BYTE InputBuffer[1200]; and for converting: cmsDoTransform(xform, InputBuffer, OutputBuffer, 300); Another way to do this could be to use arrays of structs: struct { BYTE r; BYTE g; BYTE b; } MyOutputBuffer[300]; =20 That is 300, pixels of r, g, b =20 struct { BYTE c; BYTE m; BYTE y; BYTE k; } MyInputBuffer[300]; That is, 300 pixels of cmyk then you could use:=20 cmsDoTransform(xform, MyInputBuffer, MyOutputBuffer, 300) Note that the number passed are pixels, not bytes. Hope this helps, Marti. ----- Original Message -----=20 From: Brian Fallon=20 To: lcm...@li...=20 Sent: Saturday, April 28, 2001 6:57 PM Subject: [Lcms-user] Idiots guide to CMYK->RGB conversions Hi, I've looked at every message on this list and I can't figure out how = to convert CMYK values into RGB values using the API I understand fully the concepts beign used here but I'm a total = beginner when it comes to the C language. Please, please, could you send me some code on how to do this... If = not please explain my question below. I've looked at the 'simple.c' file included with the source and I cant = figure how to use it? What type are inputBuffer & outputBuffer. Do I = pass an array of values into the function cmsDoTransform()? here is what I have being messing around with so far (see below), If = anyone could make this work I would be able to adapt it into a simple = program and that's all I need. Thanks a million.... Brian Fallon SHORT inputBuffer[] =3D {0x00,0x00,0x00,0x00}; SHORT outputBuffer[3]; cmsHPROFILE hInProfile, hOutProfile; cmsHTRANSFORM hTransform; hInProfile =3D = cmsOpenProfileFromFile("D:/Downloads/Development/lcms/lcms107b/profiles/t= r01_d50.icm", "r"); hOutProfile =3D = cmsOpenProfileFromFile("D:/Downloads/Development/lcms/Lcms107b/profiles/s= RGB Color Space Profile.ICM", "r");=20 hTransform =3D cmsCreateTransform(hInProfile, TYPE_CMYK_16, = hOutProfile, TYPE_RGB_8, INTENT_PERCEPTUAL, 0); cmsDoTransform(hTransform, inputBuffer, outputBuffer, 1); cmsDeleteTransform(hTransform); cmsCloseProfile(hInProfile); cmsCloseProfile(hOutProfile); printf("Input values: cmyk( %d, %d, %d, %d )\n", inputBuffer[0], = inputBuffer[1], inputBuffer[2], inputBuffer[3]); printf("Input values: rgb( %d, %d, %d)\n", outputBuffer[0], = outputBuffer[1], outputBuffer[2]); return 0;=20 } |