Platforms to show: All Mac Windows Linux Cross-Platform
/Images/PNG/Filters and Interlace
Required plugins for this example: MBS Main Plugin, MBS Images Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/PNG/Filters and Interlace
This example is the version from Sun, 5th May 2018.
Project "Filters and Interlace.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
// Write a RGBA PNG file
dim current as Picture = LogoMBS(500) // needs Main Plugin
// show in window
window1.Backdrop = current
prefix = "MBS "
test current
prefix = "test "
dim f as FolderItem = SpecialFolder.Desktop.Child("test.png")
if f.Exists then
current = Picture.Open(f)
test current
end if
End EventHandler
Sub Write(current as picture, interlace as Boolean, filter as integer, fname as string)
dim name as string = prefix + fname
if interlace then
name = name + " interlaced"
end if
name = name + ".png"
dim p as new PNGWriterMBS
dim f as FolderItem = SpecialFolder.Desktop.Child(name)
if p.OpenWriteDestination(f) then // open file
if p.SetRGBPicture(current) then // set picture to write
if p.SetHeader(interlace, filter) then // setup file header
if p.SetGamma(0) then // and default gamma
if p.WriteInfo then // write file header
if p.WriteRows then // write pixels
if p.WriteEnd then // and write file end
// ok
end if
end if
end if
end if
end if
end if
end if
End Sub
Sub test(current as Picture)
write current, false, -1, "default"
write current, true, -1, "default"
const PNG_NO_FILTERS = 0
const PNG_FILTER_NONE = 8
const PNG_FILTER_SUB = 16
const PNG_FILTER_UP = 32
const PNG_FILTER_AVG = 64
const PNG_FILTER_PAETH = 128
const PNG_FILTER_ALL = 248
write current, false, 0, "no filter"
write current, true, 0, "no filter"
write current, false, PNG_FILTER_ALL, "all filter"
write current, true, PNG_FILTER_ALL, "all filter"
write current, false, PNG_FILTER_AVG, "avg filter"
write current, true, PNG_FILTER_AVG, "avg filter"
write current, false, PNG_FILTER_PAETH, "paeth filter"
write current, true, PNG_FILTER_PAETH, "paeth filter"
write current, false, PNG_FILTER_SUB, "sub filter"
write current, true, PNG_FILTER_SUB, "sub filter"
write current, false, PNG_FILTER_UP, "up filter"
write current, true, PNG_FILTER_UP, "up filter"
End Sub
Property prefix As string
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class Window1 Inherits Window
End Class
End Project
The items on this page are in the following plugins: MBS Images Plugin.