Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Picture Plugin
Last modified Sun, 17th Mar 2012.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /Picture/Savebinarypicture
Download this example: Savebinarypicture.zip
Project "Savebinarypicture.xojo_binary_project"
FileTypes
Filetype application/binary
Filetype special/any
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
dim f as folderItem
dim b as binaryStream
dim s as string
f=SpecialFolder.Desktop.child("test.bin")
if f<>nil and f.exists then
b=f.openasbinaryFile(False)
if b<>nil then
s=b.read(b.length)
b.close
canvas1.backdrop=BinaryStringtoPictureMBS(s)
else
msgBox "Error opening file."
end if
else
msgBox "File not found."
end if
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim f as folderItem
dim b as binaryStream
dim s as string
f=SpecialFolder.Desktop.child("test.bin")
if f<>nil then
b=f.createbinaryFile("application/binary")
if b<>nil then
s=PicturetoBinaryStringMBS(canvas1.backdrop)
if s<>"" then
b.write s
b.close
msgBox "File written."
else
msgBox "Failed to make binary data."
end if
else
msgBox "Error creating file."
end if
else
msgBox "File not found."
end if
End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim f as folderItem
dim p as picture
f=getopenFolderItem("special/any")
if f<>nil then
p=f.openaspicture
if p<>Nil then
canvas1.backdrop=p.CloneMBS
end if
end if
End EventHandler
End Control
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project
Download this example: Savebinarypicture.zip
The items on this page are in the following plugins: MBS Picture Plugin.