Xojo Conferences

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.rbp"
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:

Feedback, Comments & Corrections

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

MBS Xojo PDF Plugins