You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LargePicture/
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
dim p as new MyPictureFactoryMBS
PictureFactoryMBS.SetFactory p
End EventHandler
End Class
Class Window1 Inherits Window
EventHandler Sub Open()
ImageFormat=PictureMBS.ImageFormatRGB
logo=new PictureMBS(LogoMBS(500))
update
End EventHandler
EventHandler Sub Resized()
update
End EventHandler
Function ImageFormatG() As Boolean
ImageFormat=PictureMBS.ImageFormatG
update
Return True
End Function
Function ImageFormatGA() As Boolean
ImageFormat=PictureMBS.ImageFormatGA
update
Return True
End Function
Function ImageFormatRGB() As Boolean
ImageFormat=PictureMBS.ImageFormatRGB
update
Return True
End Function
Function ImageFormatRGBA() As Boolean
ImageFormat=PictureMBS.ImageFormatRGBA
update
Return True
End Function
Sub update()
p=new PictureMBS(Width,Height,ImageFormat)
if mode=0 then
call p.ScaleFast(logo, Width, Height)
else
// we need a temporary picture
// provide the temp picture outself:
'dim temp as new PictureMBS(Width, p.Height, PictureMBS.ImageFormatScaling)
'
'if temp.Valid=false then
'MsgBox "Out of memory"
'quit
'else
'call p.Scale(logo, temp, mode, Width, Height)
'end if
// or do it automatically using the PictureFactoryMBS:
if p.Scale(logo, nil, mode, Width, Height)=false then
MsgBox "Out of memory"
quit
end if
end if
Backdrop=p.CopyPicture
Title=str(Width)+" x "+str(Height)+" with mode "+str(mode)
End Sub
Property ImageFormat As Integer
Property Mode As Integer
Property Private logo As picturembs
Property p As PictureMBS
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"
MenuItem ScaleModeMenu = "Scale Mode"
MenuItem ScaleMode(0) = "Fast"
MenuItem ScaleMode(1) = "Triangle"
MenuItem ScaleMode(2) = "Box"
MenuItem ScaleMode(3) = "Lanczos3"
MenuItem ScaleMode(4) = "Lanczos8"
MenuItem ScaleMode(5) = "Mitchell"
MenuItem ScaleMode(6) = "Poly3"
MenuItem ScaleMode(7) = "Cubic"
MenuItem ImageModeMenu = "Image Mode"
MenuItem ImageFormatRGB = "RGB"
MenuItem ImageFormatRGBA = "RGBA"
MenuItem ImageFormatG = "G"
MenuItem ImageFormatGA = "GA"
End MenuBar
Class ScaleMenuItem Inherits MenuItem
EventHandler Function Action() As Boolean
window1.mode=me.Index
window1.Update
End EventHandler
EventHandler Sub EnableMenu()
me.Checked=window1.mode=index
me.Enable
End EventHandler
End Class
Class MyPictureFactoryMBS Inherits PictureFactoryMBS
EventHandler Function NewPictureMBS(Width as integer, Height as integer, ImageFormat as integer) As PictureMBS
Return new PictureMBS(Width, Height, ImageFormat)
End EventHandler
End Class