Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/PICT test with CoreGraphics/test
Function:
Required plugins for this example: MBS MacCG Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/PICT test with CoreGraphics/test
This example is the version from Thu, 6th Apr 2016.
Project "test.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawPicture OpenAsPicturePict,0,0 End EventHandler
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawPicture OpenAsPicturePict,0,0,300,300,0,0,OpenAsPicturePict.Width,OpenAsPicturePict.Height End EventHandler
End Control
Control Canvas3 Inherits Canvas
ControlInstance Canvas3 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawPicture QTImporterPict,0,0,72,72,0,0,QTImporterPict.Width,QTImporterPict.Height End EventHandler
End Control
Control Canvas4 Inherits Canvas
ControlInstance Canvas4 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawPicture QTImporterPict,0,0,300,300,0,0,QTImporterPict.Width,QTImporterPict.Height End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() dim p as Picture dim f as FolderItem f=FindFile("test.pic") OpenAsPicturePict=f.OpenAsPicture QTImporterPict=OpenPicture(f) 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
Function OpenPicture(f as folderitem) As picture dim p as new QDPictMBS(f) if p.Handle=0 then Return nil // failed dim w as Double = p.Width * p.HorizontalResolution / 72.0 dim h as Double = p.Height * p.VerticalResolution / 72.0 dim c as new CGPictureContextMBS(w, h) if c.Handle=0 then Return nil // failed dim r as CGRectMBS = CGMakeRectMBS(0,0,w,h) // optional: clear background c.ClearRect r // draw pict p.DrawToCGContext(c, r) // now get the picture and mask and combine them: dim pic as picture = c.CopyPicture dim mask as Picture = c.CopyPictureMask pic.mask.Graphics.DrawPicture mask,0,0 Return pic End Function
Property Protected OpenAsPicturePict As picture
Property Protected QTImporterPict As picture
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

Feedback, Comments & Corrections

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





Links
MBS Xojo Plugins