Rank: Member
Groups: Joined: 3/1/2005(UTC) Posts: 2
|
hello, is it possible for me to convert cmyk information (not from a jpeg nor gif png) (cmyk information --- 0.1233 0.1123 0.4422 0.2222 which is extracted from PDF file. ) to RGB with ICM using graphics mill component?
the reason why i'm trying to do this is obviously if i apply the formula to convert CMYK to RGB the result color is so lighter than color's in CMYK viewed by PHOTOSHOP.
I have downloaded the demo version and found out that we can load jpeg,gif and convert the color space to others.
but i couldn't find any example source code or doc about just one color to other color spaced color conversion.
so please if this is possible, please post an example code for me. thank you. and i'll buy pretty this product pretty soon (lots of them if this is possible.) ^^
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
Hello, An ActiveX version of Graphics Mill does not allow converting individual color. However it is available in the .NET version. If you cannot use Graphics Mill for .NET, the only way to convert the color is to create a bitmap 1x1 and your color value into the single pixel. I have wrote a simple code sample demonstrating this. I had to fight with conversion from float CMYK channel values to the 32-bit CMYK pixel value (because of poor bitwise operations support in VB6). But fortunately I have found a workaround for a lack of bitwise shift operation and overflow. Code: Dim fltCyan As Single
Dim fltMagenta As Single
Dim fltYellow As Single
Dim fltBlack As Single
' I assume that CMYK values can vary in range [0, 1]
fltCyan = 0.1233
fltMagenta = 0.1123
fltYellow = 0.4422
fltBlack = 0.2222
Dim cmyk As Long
' If the high byte is more than 7F (and therefore the highest bit = 1), the overflow
' may occur. That's why we need to handle it separately.
If fltCyan <= 0.5 Then
cmyk = CLng(CLng(fltBlack * 255) Or CLng((fltYellow * 255) * &H100 And &HFF00) Or CLng((fltMagenta * 255) * &H10000 And &HFF0000) Or CLng((fltCyan * 255) * &H1000000 And &HFF000000))
Else
cmyk = CLng(CLng(fltBlack * 255) Or CLng((fltYellow * 255) * &H100 And &HFF00) Or CLng((fltMagenta * 255) * &H10000 And &HFF0000) Or CLng((CByte(fltCyan * 255) And &H7F) * &H1000000 And &HFF000000)) Or &H80000000
End If
MsgBox Hex(cmyk)
Dim objBitmap As New Bitmap
' This line creates 1x1 bitmap which contains the necessary CMYK value.
objBitmap.CreateNew 1, 1, Format32bppCmyk, cmyk, Nothing
' Do not forget to set the color management up.
objBitmap.Data.ColorManagement.Enabled = True
objBitmap.Data.ColorManagement.DataProfile = "c:\inputCMYK.icc"
objBitmap.Data.ColorManagement.RgbProfile = "c:\outputRGB.icc"
' Start conversion
objBitmap.Data.ConvertTo24bppRgb
Dim rgb As Long
' This line specifies that we want to return the value in the format which is
' used in VB6.
objBitmap.ColorTreatment = ColorTreatmentColorref
' Get converted RGB value
rgb = objBitmap.Data.Pixels(0, 0)
' Visualize the result.
Form1.BackColor = rgb
MsgBox Hex(rgb)
Hope this helps. Edited by user Monday, December 24, 2007 4:09:42 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Joined: 3/1/2005(UTC) Posts: 2
|
Hello, thank you for your help on this problem. I was able to modify it to ASP source code and tested bunch of colors.. for the code down below the RGB color should be #BFD40D ( in photoshop) but what i'm getting is #1C8CC6 which is totally out of color range.. is this problem of graphics mill or simply the hex conversion problem? can you please test it out and where is wrong? this is the testing URL for this problem.. thank you. http://www.ohteam.com/cmyk.aspCode:<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
fltCyan = 0.25
fltMagenta = 0.6
fltYellow = 1.00
fltBlack = 0.00
Dim cmyk ' As Long
' If the high byte is more than 7F (and therefore the highest bit = 1), the overflow
' may occur. That's why we need to handle it separately.
If fltCyan <= 0.5 Then
cmyk = CLng(CLng(fltBlack * 255) Or CLng((fltYellow * 255) * &H100 And &HFF00) Or CLng((fltMagenta * 255) * &H10000 And &HFF0000) Or CLng((fltCyan * 255) * &H1000000 And &HFF000000))
Else
cmyk = CLng(CLng(fltBlack * 255) Or CLng((fltYellow * 255) * &H100 And &HFF00) Or CLng((fltMagenta * 255) * &H10000 And &HFF0000) Or CLng((CByte(fltCyan * 255) And &H7F) * &H1000000 And &HFF000000)) Or &H80000000
End If
'Create Bitmap object
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
' This line creates 1x1 bitmap which contains the necessary CMYK value.
objBitmap.CreateNew 1, 1, Format32bppCmyk, cmyk, Nothing
' Do not forget to set the color management up.
objBitmap.Data.ColorManagement.IsEnabled = True
objBitmap.Data.ColorManagement.DataProfile = Server.MapPath("AdobeCMYK.icm")
objBitmap.Data.ColorManagement.RgbProfile = Server.MapPath("sRGB.icm")
' Start conversion
objBitmap.Data.ConvertTo24bppRgb
Dim rgb
' This line specifies that we want to return the value in the format which is
' used in VB6.
objBitmap.ColorTreatment = ColorTreatmentColorref
' Get converted RGB value
rgb = objBitmap.Data.Pixels(0, 0)
' Visualize the result.
response.Write Hex(rgb)
%>
Edited by user Monday, December 24, 2007 4:10:17 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
Could you send a CMYK color profile you use (as far as I understand, the RGB profile is a standard sRGB profile)? Please submit case with these files. Edited by user Friday, May 23, 2008 3:34:43 PM(UTC)
| Reason: Not specified
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.