Example: /Images/PNG/Write PNG Palette image

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/PNG/Write PNG Palette image


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/PNG/Write PNG Palette image

This example is the version from Sun, 10th Dec 2016.

Project "Write PNG Palette image.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() dim p as Picture dim colors(256) as color dim alphas(256) as integer dim i,x,y as integer dim r as RGBSurface dim f as FolderItem for i=0 to 255 colors(i)=rgb(Rnd*256, rnd*256, rnd*256) next for i=0 to 255 // order colors by alphas alphas(i)=rnd*256 next // just for testing for i=0 to 127 alphas(i)=255 // 100% opaque next p = new Picture(100,100,32) r=p.RGBSurface for y=0 to 99 for x=0 to 99 r.Pixel(y,x)=colors(y+x) next next f=SpecialFolder.desktop.Child("test.png") if f.SaveAs8BitPNGMBS(p, colors, 0) then Title="ok" else Title="failed" end if f=SpecialFolder.desktop.Child("testalpha.png") if f.SaveAs8BitAlphaPNGMBS(p, colors, alphas, 0) then Title="ok" else Title="failed" end if Backdrop=p End EventHandler
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
End Project

See also:

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


💬 Ask a question or report a problem