Object2D in PDF documentation

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 (document’s 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):

  1. 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.

  2. Platform not supported on “Dim mSavePicture As New Picture(500,500)
    Set GDI+ to be able to continue.

  3. Draw the Oject2D Works (draws the object)

  4. Save the Oject2D Works (save the object that can be read elsewhere)

  5. 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.

Hi Emile, I think a non-PICT format for O2D graphics in on the Xojo agenda but seems to be a long time coming. Copying an O2D picture to the clip results in an “unsupported” trap. However, vector graphics has long been a major feature of Xojo and its past instantiations and has not been depreciated so, hopefully, the issue will be resolved in some future version.

There was some much earlier discussion on vector graphics formats when PICT was first depreciated. SVG is the obvious standard, Adobe has promoted it and there are now many low-cost graphics editors that support it, some even have it as a native file format. However, few document processors will import it. I added an export to SVG capability some years ago to support my users who wanted high-quality vector graphics, and that has been very well-received.

One problem I see in raising the priority of support for O2D to some non-PICT format is that there is no feedback case explicitly for this. There is one for PDF generation in general, but O2D to PDF is minor compared with that.

Meanwhile use of O2D continues to work very well under Windows but is extremely problematic on Macs even under Carbon (PICT – no Unicode support).

Even when PICT was ‘acceptable’, saving a vector image has been deplorable in RealBasic for over 6 years.
At which time I gave up and started creating PDF files instead.
Many apps can open and even edit PDF with scalable objects, but its a compromise I didn’t really want to make.
SVG would be funky … browser support was all but gone a few years ago, but now it seems to be gaining favour again.

Hi Jeff, yes PDF seems to be the way the industry is going for a vector graphics interchange format. I use latex extensively and PDF has become the standard for incorporating images. Currently I export graphics from my Xojo app in SVG, convert them to PDF in Illustrator and incorporate them in tex documents. Works well and the images scale with great clarity and precision.

There are cheaper apps than Illustrator for SVG to PDF conversion. One needs to check that they export the image at size, not as a page, and that they do not convert to bitmap to do so. There is also a free SVG to PDF conversion service on the web at http://www.fileformat.info/convert/image/svg2pdf.htm which is excellent.

I assume part of the reason for Xojo’s delay in implementing a new O2D export format has been tracking what is becoming the most widely used format – PDF does seem to have won out.

Thank you for your answers.

On OS X, Preview does not support svg (unfortunately).

What is the situation on Windows ?

The G.I.M.P. opens PDF files, but I do not check it for O2D recently.

Due to resize bug (Grow the simple image), I gave up 02D years ago too.

My recent interest occured when I read the pdf doc book (when I read “Vector graphics are stored as PICT files on OS X” on OS).

Is one of you was able to open a O2D image file lately on Windows XP ?