Platforms to show: All Mac Windows Linux Cross-Platform

/LCMS/RGB to CMYK and back
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /LCMS/RGB to CMYK and back
This example is the version from Fri, 4th Feb 2010.
Notes: Last modified: Fri, 4th Feb 2010
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = &Beenden
Const kEditClear =
End Class

Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Change() Handles Event
run me.ListIndex

End Sub
End ControlInstance

// Event implementations
Sub Open()

run LCMSMBS.INTENT_ABSOLUTE_COLORIMETRIC

End Sub

// Methods
Function NewPicture(c as Color) As Picture
dim p as Picture = NewPicture(100,100,32)

p.Graphics.ForeColor=c
p.Graphics.FillRect 0,0,100,100

Return p

End Function
Sub test(canvas1 as canvas, canvas2 as canvas, c as color, info as StaticText, intent as integer)
dim ct as CMTransformMBS
dim mi,mo as MemoryBlock
dim pi as CMProfileMBS
dim po as CMProfileMBS
dim f as FolderItem

// you find this profiles on Mac OS X in /System/Library/ColorSync/Profiles
f=SpecialFolder.Desktop.Child("Generic RGB Profile.icc")
pi=f.OpenAsCMProfileMBS

if pi = nil then
MsgBox "Failed to find the profile."+EndOfLine+EndOfLine+f.Name
end if

f=SpecialFolder.Desktop.Child("Generic CMYK Profile.icc")
po=f.OpenAsCMProfileMBS

if po = nil then
MsgBox "Failed to find the profile."+EndOfLine+EndOfLine+f.Name
end if

ct=LCMSMBS.CreateTransform(pi,po,intent)

canvas1.Backdrop = NewPicture(c)

' ... fill c
mi=NewMemoryBlock(8) // RGB
mo=NewMemoryBlock(8) // CMYK

mi.UShort(0)=c.red*257
mi.UShort(2)=c.green*257
mi.UShort(4)=c.blue*257

if ct.TransformMem(mi,mo,1) then
'ok

dim cc as integer = mo.UShort(0)/257 // C
dim mm as integer = mo.UShort(2)/257 // M
dim yy as integer = mo.UShort(4)/257 // Y
dim kk as integer = mo.UShort(6)/257 // K

// convert back
ct=LCMSMBS.CreateTransform(po,pi,intent)

mi.UShort(0) = cc*257 // C
mi.UShort(2) = mm*257 // M
mi.UShort(4) = yy*257 // Y
mi.UShort(6) = kk*257 // K

if ct.TransformMem(mi,mo,1) then
dim rr as integer = mo.UShort(0)/257 // R
dim gg as integer = mo.UShort(2)/257 // G
dim bb as integer = mo.UShort(4)/257 // B

info.text = str(c.red)+" "+str(c.Green)+" "+str(c.Blue)+EndOfLine+_
str(cc)+" "+str(mm)+" "+str(yy)+" "+str(kk)+EndOfLine+_
str(rr)+" "+str(gg)+" "+str(bb)+EndOfLine

canvas2.Backdrop = NewPicture(rgb(rr,gg,bb))

end if

end if

End Sub
Sub run(intent as integer)

test canvas1, canvas2, &cFF0000, StaticText1, intent
test canvas3, canvas4, &c00FF00, StaticText2, intent
test canvas5, canvas6, &c0000FF, StaticText3, intent
test canvas7, canvas8, &cFFFFFF, StaticText4, intent
test canvas9, canvas10, &c000000, StaticText5, intent
test canvas11, canvas12, &c777777, StaticText6, intent



End Sub
End Class





Links
MBS Realbasic Chart Plugins - Pfarrgemeinde Messdiener Nickenich