Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/jpeg load crashtest/OpenAsJPEG 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/JPEG/jpeg load crashtest/OpenAsJPEG Test

This example is the version from Mon, 5th May 2019.

Project "OpenAsJPEG Test.xojo_binary_project"
FileTypes
Filetype jpeg
End FileTypes
Class TestWindow Inherits Window
Control out Inherits Canvas
ControlInstance out Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if p <> nil then g.DrawPicture p, 0, 0 end if End EventHandler
End Control
Control RadioRB Inherits RadioButton
ControlInstance RadioRB Inherits RadioButton
EventHandler Sub Action() runbutton.enabled=true End EventHandler
End Control
Control RadionMBS Inherits RadioButton
ControlInstance RadionMBS Inherits RadioButton
EventHandler Sub Action() runbutton.enabled=true End EventHandler
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control Runbutton Inherits PushButton
ControlInstance Runbutton Inherits PushButton
EventHandler Sub Action() dim b as binaryStream dim ff,f as folderItem dim i,n as integer dim t as textoutputStream dim s as string dim pre,post as string dim le as integer dim max as integer if keyboard.asyncOptionKey then // press option for 100 tests. max=100 else max=1 end if ff=SpecialFolder.Desktop.Child("log") // our log file // load the template jpeg into a buffer f=FindFile("template.jpg") b=f.openasbinaryFile(false) le=b.length s=b.read(le) b.close // for the log if RadionMBS.value then pre="We copy " post=" Bytes to test.jpg and try OpenJPEGfile than." else pre="We copy " post=" Bytes to test.jpg and try f.openaspicture than." end if // test.jpg will be the test file f=FindFile("test.jpg") for i=1 to max n=lenb(s)*rnd b=f.createBinaryFile("jpeg") b.write leftb(s,n) b.close if ff.exists then t=ff.appendToTextFile else t=ff.createTextFile end if t.writeline ""+format(n,"0") t.close if RadionMBS.value then p=f.OpenAsJPEGMBS(checkBox1.value) else p=f.openaspicture end if out.Invalidate updatenow // for Mac OS X to move the content to screen info.text="This Test.jpg has only "+str(n)+" bytes from the original file which has "+str(le)+" bytes." next t.close End EventHandler
End Control
Control info Inherits Label
ControlInstance info Inherits Label
End Control
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
Property p As Picture
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

See also:

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


The biggest plugin in space...