Platforms to show: All Mac Windows Linux Cross-Platform

/Images/PNG/PNG Test/PNG Test


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/PNG Test/PNG Test

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

Project "PNG Test.xojo_binary_project"
FileTypes
Filetype image/png
End FileTypes
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 PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() Dim p As Picture Dim f As FolderItem Dim s As String Dim success As Boolean s = "test.png" // Comp the two images together for the hell of it p = new Picture(Canvas1.Backdrop.Width, Canvas1.Backdrop.Height, 32) p.Graphics.DrawPicture (Canvas1.Backdrop, 0, 0, p.Width, p.Height) p.Graphics.DrawPicture (Canvas2.Backdrop, 0, 0, p.Width, p.Height) // Draw in a cheap mask for testing if CheckBox1.Value then s = "test with mask.png" p.Mask.Graphics.ForeColor = &cFFFFFF p.Mask.Graphics.FillRect ( 0, 0, p.Width, p.Height ) p.Mask.Graphics.ForeColor = &c000000 p.Mask.Graphics.FillOval ( 0, 0, p.Width, p.Height ) end if // Save it f = GetSaveFolderItem( "image/png", s ) if f <> Nil then success = f.SaveAsPNGMBS(p, 0.0) if NOT success then MsgBox "Save Failed!" end if end if End EventHandler
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() test End EventHandler
End Control
EventHandler Sub Open() dim f as FolderItem dim p as PNGPictureMBS f=FindFile("arches.png") p=f.OpenAsPNGMBS(0) if p<>nil then Canvas1.Backdrop = p.CombinePictureWithMask end if f=FindFile("radio.png") p=f.OpenAsPNGMBS(0) if p<>Nil then Canvas2.Backdrop = p.CombinePictureWithMask end if 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
Protected Sub test() dim s1,s2 as string s1=PictureToPNGStringMBS(Canvas1.Backdrop,0) s2=PictureToPNGStringMBS(Canvas2.Backdrop,0) MsgBox str(lenb(s1))+" bytes for left image and "+str(lenb(s2))+" bytes for right image." Canvas1.Backdrop=nil Canvas2.Backdrop=nil Canvas2.Backdrop=PNGStringToPictureMBS(s1,0) Canvas1.Backdrop=PNGStringToPictureMBS(s2,0) End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...