page 96 of the current pdf book named UserGuide-Framework.pdf, Saving and Loading Vector Graphics is plainly wrong.
Xojo 2013r4.1
OS X 10.8.5
Historically, my attention was alerted when I read Vector graphics are stored as PICT files on OS X then I keep the pdf open in Preview for some weeks (maybe more, but it is the pdf that comes with 2013r4.1).
Minutes ago, I falled in a bug elsewhere (not programming with Xojo) and I saw the PDF. I decided to read it, check it and here I am.
The example #1 works if modified as below:
Dim r As New RoundRectShape
Dim mSavePicture As New Picture(500,500)
r.Width = 120
r.Height = 120
r.Border = 100
r.BorderColor = RGB(0,0,0) // black
r.FillColor = RGB(255,102,102)
r.CornerHeight = 15
r.CornerWidth = 15
r.BorderWidth = 2.5
mSavePicture.Graphics.DrawObject(r,100,100)
Self.Backdrop = mSavePicture
Object2DPicture = mSavePicture
Nota for the Xojo users: the line starting with mSavePicture.Graphics.DrawObject appears as this:
mSavePicture.Graphics.DrawObject(r,
100, 100)
Yes, on two lines. What a newbie will understand reading that ?
Also, the last line
have nothing to do there, in the context. I replaced with a different one (read above):
// Line to remove
g.DrawPicture(p, 0, 0)
BTW: I added a Property in Window1 for the mSavePicture Picture: Object2DPicture As Picture
The part to save the Object2D:
I get a NilObjectException in:
mSavePicture.Save(file, Picture.SaveAsDefaultVector)
mSavePicture is Nil said the debugger.
As already said, I added in Window1: Object2DPicture As Picture.
So the new code to save as picture is:
Dim file As FolderItem
If TargetMacOS Then
file = GetSaveFolderItem("", "vector.pict")
Else
file = GetSaveFolderItem("", "vector.emf")
End If
If file <> Nil Then
Object2DPicture.Save(file, Picture.SaveAsDefaultVector)
End If
To Open a vector picture I only added a line into the “If p <> Nil Then” Block: Object2DPicture = p
Dim file As FolderItem
file = GetOpenFolderItem("")
If file <> Nil Then
Dim p As Picture
p = file.OpenAsVectorPicture
If p <> Nil Then
Object2DPicture = p
Self.Backdrop = p
End If
End If
I add it just to be sure everything else will work fine.
Nota: I put the code in three PushButtons located in Window1.
BTW: on OS X 10.8.5 (and some prior versions), a PICT file is a Image QuickDraw (documents type).
We all know that QuickDraw documents are deprecated on OS X even if now they can be displayed (loaded in Preview). But on Mavericks ? And in 10.10 ?
You can open the file with Preview, but you cannot copy its contents.
You cannot open it with Safari (Safari delegate the process to Preview).
The G.I.M.P. refuse to open it.
At last, if no one report anything (as it seems), it is because no one is saving / loading Object2D (or found a solution).
On Windows XP (yes, the deprecated platform):
-
Paint cannot open this file
I used Open with Xojo to open the project.
I also set Use Xojo to always open that kind of documents. -
Platform not supported on “
Dim mSavePicture As New Picture(500,500)
”
Set GDI+ to be able to continue. -
Draw the Oject2D Works (draws the object)
-
Save the Oject2D Works (save the object that can be read elsewhere)
-
Open the Oject2D crashed.
Nota: the file was saved correctly as I could saw its contents in the Explorer. I also was able to open it using LibreOffice.Draw (only the rendered part ?).
That is all I can say for this subject.