Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacBase/ConvertToSRGB
This example is the version from Thu, 29th Mar 2017.
Project "ConvertToSRGB.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() const NSColorRenderingDefault = 0 const NSColorRenderingAbsoluteColorimetric = 1 const NSColorRenderingRelativeColorimetric = 2 const NSColorRenderingPerceptual = 3 const NSColorRenderingSaturation = 4 // pick a file // e.g. CMYK tiff file dim f as FolderItem = GetOpenFolderItem("") if f = nil then quit end if // load picture dim n as new NSImageMBS(f) // get first representation dim reps() as NSImageRepMBS = n.representations // get as bitmap object dim v as Variant = reps(0) dim bitmap as NSBitmapImageRepMBS = v // get target color space Dim sRGBColorSpace as NSColorSpaceMBS = NSColorSpaceMBS.sRGBColorSpace // convert to SRGB dim NewBitmap as NSBitmapImageRepMBS = bitmap.bitmapImageRepByConvertingToColorSpace(sRGBColorSpace, NSColorRenderingDefault) dim NewImage as new NSImageMBS NewImage.addRepresentation NewBitmap // make JPEG dim JPEGData as string = NewImage.JPEGRepresentationWithCompressionFactor(0.9) // and save to file dim ff as FolderItem = GetFolderItem("RGBImage.jpg") dim b as BinaryStream = BinaryStream.Create(ff, true) b.Write JPEGData dim w as new PictureWindow W.Backdrop = NewImage.CopyPictureWithAlpha End EventHandler
End Class
Class PictureWindow Inherits Window
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

Feedback, Comments & Corrections

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

MBS Xojo Plugins