Platforms to show: All Mac Windows Linux Cross-Platform
/Images/LargePicture/JPEG Modes
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/LargePicture/JPEG Modes
This example is the version from Sun, 17th Mar 2012.
Project "JPEG Modes.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
EventHandler Sub Open()
// load grayscale jpeg file to gray PictureMBS
testDataGray
// load RGB jpeg file to RGB PictureMBS
testDataRGB
// load RGB jpeg file to gray PictureMBS
testDataRGBtoGray
// load RGB jpeg file to red channel of RGB PictureMBS
testDataGrayRedChannel
End EventHandler
Sub testDataGray()
dim j as new JPEGImporterMbs
dim f as FolderItem
dim p as PictureMBS
dim i,c as integer
f=SpecialFolder.Desktop.Child("gray.jpg")
j.File=f
j.Mode=j.ModeGraybyRow
if j.InitJPEG then
p=new PictureMBS(j.Width, j.Height, PictureMBS.ImageFormatG)
c=j.Height-1
for i=0 to c
if j.LoopJPEG=0 then
p.RowInFormat(i, PictureMBS.ImageFormatG)=j.PictureData
end if
next
j.FinishJPEG
canvas1.Backdrop=p.CopyPicture
else
MsgBox "Failed to open gray.jpg on the desktop."
quit
end if
End Sub
Sub testDataGrayRedChannel()
dim j as new JPEGImporterMbs
dim f as FolderItem
dim red,p as PictureMBS
dim i,c as integer
f=SpecialFolder.Desktop.Child("gray.jpg")
j.File=f
j.Mode=j.ModeGraybyRow
if j.InitJPEG then
p=new PictureMBS(j.Width, j.Height, PictureMBS.ImageFormatRGB)
p.DebugPictureEnabled=True
red=p.RedChannel
red.DebugPictureEnabled=True
c=j.Height-1
for i=0 to c
if j.LoopJPEG=0 then
// writing gray picture data to red channel
red.RowInFormat(i, PictureMBS.ImageFormatG)=j.PictureData
end if
next
j.FinishJPEG
canvas3.Backdrop=p.CopyPicture
else
MsgBox "Failed to open gray.jpg on the desktop."
quit
end if
End Sub
Sub testDataRGB()
dim j as new JPEGImporterMbs
dim f as FolderItem
dim p as PictureMBS
dim i,c as integer
f=SpecialFolder.Desktop.Child("rgb.jpg")
j.File=f
j.Mode=j.ModeRGBbyRow
if j.InitJPEG then
p=new PictureMBS(j.Width, j.Height, PictureMBS.ImageFormatRGB)
c=j.Height-1
for i=0 to c
if j.LoopJPEG=0 then
p.RowInFormat(i, PictureMBS.ImageFormatRGB)=j.PictureData
end if
next
j.FinishJPEG
canvas2.Backdrop=p.CopyPicture
else
MsgBox "Failed to open rgb.jpg on the desktop."
quit
end if
End Sub
Sub testDataRGBtoGray()
dim j as new JPEGImporterMbs
dim f as FolderItem
dim p as PictureMBS
dim i,c as integer
f=SpecialFolder.Desktop.Child("rgb.jpg")
j.File=f
j.Mode=j.ModeRGBbyRow
if j.InitJPEG then
p=new PictureMBS(j.Width, j.Height, PictureMBS.ImageFormatG)
c=j.Height-1
for i=0 to c
if j.LoopJPEG=0 then
// writing RGB data to a gray picture will auto convert data to gray
p.RowInFormat(i, PictureMBS.ImageFormatRGB)=j.PictureData
end if
next
j.FinishJPEG
canvas4.Backdrop=p.CopyPicture
else
MsgBox "Failed to open rgb.jpg on the desktop."
quit
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.