Platforms to show: All Mac Windows Linux Cross-Platform

/Images/LCMS2/RGB to Lab and back with floats


Required plugins for this example: MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LCMS2/RGB to Lab and back with floats

This example is the version from Sun, 10th Dec 2016.

Project "RGB to Lab and back with floats.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
End Control
Control Canvas3 Inherits Canvas
ControlInstance Canvas3 Inherits Canvas
End Control
Control Canvas4 Inherits Canvas
ControlInstance Canvas4 Inherits Canvas
End Control
Control Canvas5 Inherits Canvas
ControlInstance Canvas5 Inherits Canvas
End Control
Control Canvas6 Inherits Canvas
ControlInstance Canvas6 Inherits Canvas
End Control
Control Canvas7 Inherits Canvas
ControlInstance Canvas7 Inherits Canvas
End Control
Control Canvas8 Inherits Canvas
ControlInstance Canvas8 Inherits Canvas
End Control
Control Canvas9 Inherits Canvas
ControlInstance Canvas9 Inherits Canvas
End Control
Control Canvas10 Inherits Canvas
ControlInstance Canvas10 Inherits Canvas
End Control
Control Canvas11 Inherits Canvas
ControlInstance Canvas11 Inherits Canvas
End Control
Control Canvas12 Inherits Canvas
ControlInstance Canvas12 Inherits Canvas
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
EventHandler Sub Change() run me.ListIndex End EventHandler
End Control
EventHandler Sub Open() run PopupMenu1.ListIndex End EventHandler
Function NewColorPicture(c as Color) As Picture dim p as Picture = new Picture(100,100,32) p.Graphics.ForeColor=c p.Graphics.FillRect 0,0,100,100 Return p End Function
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, StaticText6, intent test canvas11, canvas12, &c777777, StaticText5, intent End Sub
Sub test(canvas1 as canvas, canvas2 as canvas, c as color, info as Label, intent as integer) dim ct as LCMS2TransformMBS dim mi,mo as MemoryBlock dim pi as LCMS2ProfileMBS dim po as LCMS2ProfileMBS dim f as FolderItem // you find this profiles on Mac OS X in /System/Library/ColorSync/Profiles pi = LCMS2ProfileMBS.CreateSRGBProfile if pi = nil then MsgBox "Failed to find the profile."+EndOfLine+EndOfLine+f.Name end if po = LCMS2ProfileMBS.CreateLab2Profile if po = nil then MsgBox "Failed to find the profile."+EndOfLine+EndOfLine+f.Name end if // get data format for 8 bit integers dim pif as integer = pi.FormatterForColorspace(8, true) dim pof as integer = po.FormatterForColorspace(8, true) dim flags as integer = LCMS2MBS.kcmsFLAGS_BLACKPOINTCOMPENSATION ct = LCMS2TransformMBS.CreateTransform(pi, pif, po, pof, intent, flags) canvas1.Backdrop = NewColorPicture(c) ' ... fill c mi=NewMemoryBlock(3*8) // RGB mo=NewMemoryBlock(3*8) // LAB mi.DoubleValue( 0)=c.red / 255.0 mi.DoubleValue( 8)=c.green / 255.0 mi.DoubleValue(16)=c.blue / 255.0 if ct.Transform(mi,mo,1) then 'ok // L = 0 to 255 // A,B = 128 is 0 point // dim L as double = mo.DoubleValue( 0) // L dim A as double = mo.DoubleValue( 8) // A dim B as double = mo.DoubleValue(16) // B // convert back ct = LCMS2TransformMBS.CreateTransform(po, pof, pi, pif, intent) if ct.Transform(mo,mi,1) then dim rr as integer = mi.DoubleValue( 0)*255.0 // R dim gg as integer = mi.DoubleValue( 8)*255.0 // G dim bb as integer = mi.DoubleValue(16)*255.0 // B info.text = str(c.red)+" "+str(c.Green)+" "+str(c.Blue)+EndOfLine+_ str(l,"0.00")+" "+str(a,"0.00")+" "+str(b,"0.00")+EndOfLine+_ str(rr)+" "+str(gg)+" "+str(bb)+EndOfLine canvas2.Backdrop = NewColorPicture(rgb(rr,gg,bb)) end if end if End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS Images Plugin.


The biggest plugin in space...