Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/PNG to JPEG with ICC Profile
Function:
Required plugins for this example: MBS Images Plugin, MBS MacCG Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/JPEG/PNG to JPEG with ICC Profile
This example is the version from Thu, 2nd Dec 2015.
Project "PNG to JPEG with ICC Profile.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim fi as FolderItem = SpecialFolder.Desktop.Child("Import.png") if not fi.exists then Break MsgBox "Please put Import.png on desktop." quit end if TestCrossPlatform #if TargetMachO then TestMacWay #endif End EventHandler
Sub TestCrossPlatform() // read with PNG dim fi as FolderItem = SpecialFolder.Desktop.Child("Import.png") dim pn as new PNGReaderMBS dim name as string dim compression as integer dim ProfileData as string if pn.OpenFile(fi) then if pn.ApplyOptions then if pn.ReadPicture then // read the ICC profile if pn.ReadICCProfile(name, compression, ProfileData) then // write JPEG dim je as new JPEGExporterMBS dim fe as FolderItem fe=SpecialFolder.Desktop.child("Export.jpg") je.File=fe je.Quality=60 // 200 dpi je.VerticalResolution = 200 je.HorizontalResolution = 200 je.ResolutionUnit = 1 // the Picture je.Picture = pn.Pict // here include the ICC profile je.ProfileData = ProfileData // and write je.Export end if end if end if end if End Sub
Sub TestMacWay() // read file using Xojo framework which uses Apple frameworks dim fi as FolderItem = SpecialFolder.Desktop.Child("Import.png") dim pi as Picture = Picture.Open(fi) // now write via plugin dim je as new JPEGExporterMBS dim fe as FolderItem fe=SpecialFolder.Desktop.child("ExportMac.jpg") je.File=fe je.Quality=60 // 200 dpi je.VerticalResolution = 200 je.HorizontalResolution = 200 je.ResolutionUnit = 1 // the picture je.Picture=pi // here we get the colorspace and include it in JPEG dim c as CGColorSpaceMBS = pi.CGColorSpaceMBS je.ProfileData = c.ICCProfile // and write je.Export End Sub
End Class
Class Window1 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 Images Plugin.




Links
MBS Xojo Plugins