Example: /Images/JPEG/PNG to JPEG with ICC Profile

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/PNG to JPEG with ICC Profile


Required plugins for this example: MBS MacCG Plugin, MBS MacCF Plugin, MBS Images 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.xojo_binary_project"
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

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


💬 Ask a question or report a problem