Platforms to show: All Mac Windows Linux Cross-Platform

/Images/JPEG/SaveJPEG without QuickTime2


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/SaveJPEG without QuickTime2

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

Project "SaveJPEG without QuickTime2.xojo_binary_project"
Class Window1 Inherits Window
Control preview Inherits Canvas
ControlInstance preview Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.drawpicture current,0,0 End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control Quality Inherits Slider
ControlInstance Quality Inherits Slider
EventHandler Sub ValueChanged() value.text=str(me.value) run preview.Invalidate End EventHandler
End Control
Control value Inherits Label
ControlInstance value Inherits Label
End Control
Control size Inherits Label
ControlInstance size Inherits Label
End Control
EventHandler Sub Open() create run End EventHandler
Sub create() dim g as graphics dim x as integer dim y as integer dim r as RGBSurface dim w as integer dim h as integer original = new Picture(preview.width,preview.height,32) r=original.RGBSurface g=original.graphics w=original.width-1 h=original.height-1 for x=0 to w for y=0 to h r.pixel(x,y)=rgb(x*255/w,y*255/h,y*255/h) next next End Sub
Sub run() dim f as folderItem dim je as JPEGExporterMBS dim ji as JPEGImporterMBS f=SpecialFolder.Desktop.child("test.jpg") je=new JPEGExporterMBS ji=new JPEGImporterMBS je.HorizontalResolution=300 je.VerticalResolution=300 je.ResolutionUnit=1 je.File=f je.Picture=original je.Quality=Quality.Value je.Export if je.ErrorCode=0 then ji.File=f ji.AllowDamaged=true ji.Import current=ji.Picture size.text=str(f.length)+" Bytes" else msgBox "Error on creating the JPEG file. "+str(je.ErrorCode)+" "+je.ErrorMessage end if End Sub
Property current As picture
Property original 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...