Platforms to show: All Mac Windows Linux Cross-Platform
/Images/LargePicture/CMYK/PictureMBS with CMYK
Required plugins for this example: MBS Images Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LargePicture/CMYK/PictureMBS with CMYK
This example is the version from Thu, 6th Apr 2016.
Project "PictureMBS with CMYK.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
RunTIFF
RunJPEG
quit
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
Sub RunJPEG()
// load cmyk
dim f as FolderItem = FindFile("MBSLogo_cmyk.jpg")
dim ji as new JPEGImporterMBS
ji.file = F
ji.mode = ji.ModeCMYK
ji.ImportCMYK
dim width as integer = ji.Width
dim height as integer = ji.Height
dim rowBytes as integer = ji.Width * 4
dim data as MemoryBlock = ji.PictureData
// Make PictureMBS and rotate it
dim pic as new PictureMBS(data, width, height, PictureMBS.ImageFormatCMYK, rowBytes)
dim output as PictureMBS = pic.Rotate90
// save jpeg
dim je as new JPEGExporterMBS
je.File = SpecialFolder.Desktop.Child("output.jpg")
je.ExportCMYK(output.Memory, output.Width, output.Height, output.RowSize)
// done
je.file.Launch
End Sub
Sub RunTIFF()
// load cmyk
dim f as FolderItem = FindFile("MBSLogo_cmyk.tif")
dim ji as new TiffPictureMBS
call ji.Open(f)
dim width as integer = ji.Width
dim height as integer = ji.Height
dim rowBytes as integer = ji.BytesPerRow
dim data as new MemoryBlock(rowBytes*height)
for i as integer = 0 to height-1
dim m as MemoryBlock = data.AddressPtrMBS(i*rowBytes)
call ji.Scanline(m, i)
next
// Make PictureMBS and rotate it
dim pic as new PictureMBS(data, width, height, PictureMBS.ImageFormatCMYK, rowBytes)
dim output as PictureMBS = pic.Rotate90
// save jpeg
dim t as new TiffPictureMBS
dim o as FolderItem = SpecialFolder.Desktop.Child("output.tif")
if t.Create(o, 0) then
t.Height = output.Height
t.Width = output.Width
t.RowsPerStrip = 1
t.PlanarConfig = t.kPlanarConfigContig
t.Photometric = t.kPhotometricSeparated
t.BitsPerSample = 8
t.SamplesPerPixel = 4
t.FillOrder = t.kFillOrderMSB2LSB
t.Orientation = t.kOrientationTopLeft
t.ResolutionUnit = t.kResUnitInch
t.VerticalResolution = 72.0
t.HorizontalResolution = 72.0
t.Compression = t.kCompressionNone
t.RowsPerStrip = 32
// copy lines
for i as integer = 0 to output.Height - 1
t.Scanline(i) = output.RowInFormat(i, PictureMBS.ImageFormatCMYK)
next
t.close
end if
// done
o.Launch
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
The items on this page are in the following plugins: MBS Images Plugin.