Platforms to show: All Mac Windows Linux Cross-Platform

/GraphicsMagick/GraphicsMagick/SVG Test/SVG Rastor


Required plugins for this example: MBS GraphicsMagick Plugin, MBS MacCG Plugin, MBS MacCF Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /GraphicsMagick/GraphicsMagick/SVG Test/SVG Rastor

This example is the version from Sat, 25th Feb 2022.

Project "SVG Rastor.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) #If TargetMacOS Then // disable the interpolation Dim CGContextRef As Integer = g.handle( g.HandleTypeCGContextRef ) dim c as CGContextMBS = CGContextMBS.contextWithCGContext(CGContextRef) c.SaveGState c.InterpolationQuality = c.kCGInterpolationNone #EndIf g.ForeColor = &c000000 g.DrawRect (0,0,me.Width,me.Height) if RastoredVectorImage <> Nil Then g.DrawPicture(RastoredVectorImage.CopyPicture,0,0) end if #If TargetMacOS Then c.RestoreGState #EndIf End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() // render with 200% if RastoredVectorImage <> Nil Then RastoredVectorImage = Nil end if SVG_File = FindFile("sunrays.svg") RastoredVectorImage = new GMImageMBS(SVG_File) Canvas1.Invalidate(False) End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() If RastoredVectorImage <> Nil Then RastoredVectorImage = Nil end if // first open file and read data in blob SVG_File = FindFile("sunrays.svg") dim stream as BinaryStream = BinaryStream.Open(SVG_File) dim data as string = stream.Read(stream.Length) dim blob as new GMBlobMBS(data) // 200% in width and height dim geo as new GMGeometryMBS("400x400") RastoredVectorImage = new GMImageMBS(blob, geo) Canvas1.Invalidate(False) End EventHandler
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 Private RastoredVectorImage As GMImageMBS
Property Private SVG_File As FolderItem
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

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


The biggest plugin in space...