Vector graphics picture won't save

Hobbyist programmer here.

I can create a picture with vector graphics but can not figure out how to save it and re-open it that way. I tried the PICTURE.SAVE method but it doesn’t work for me. There’s no parameter, at least not documented, that I can find that allows for saving as a vector-graphics file. I did discover using:

MyPicture.Save(f, Picture.SaveAsDefaultVector)

Also tried

MyPicture.Save(f, Picture.SaveAsWindowsEMF)

But it doesn’t save. No error message but also, no file result.

Windows 10 Pro platform.

Any tips would be appreciated.

Have you setup the f parameter before hand. For example using a SaveFileDialog?


f = gAppFolder.Child(“A.PuzzlePicts”).Child(SaveName)

I also tried using the dialog methods. No luck.

I’m assuming the gAppFolder is correctly initialised and “A.PuzzlePicts” folder exists. Do you get any error messages at all.

No error messages. I stepped through process, it appears to save, but there’s no result. When it went to save the file with the .Saveasdefaultvector extension I noticed it the File Exists property flipped to False.

But no error messages.

I was/am able to save this same file in the same location if I just save it as a BMP or TIFF file.

Did you draw in a vector way? Take the example here:

I think I did. The entire graphics/picture realm is a hard world for me to crack. But that said, I took the picture from a fully functional, vectored drawing on another window. I need the vectors because I don’t want pixellated text. Works beautifully in the other window. Prints to a beautiful PDF file. But when I copy this graphic and try to save it … it won’t happen.

And I have scoured the documentation including the part you posted.

Have you tried copying the example in the documentation and seeing if that works with your saving code. Then you will know if it is your drawing code or something with the saving code.

No, haven’t tried that. I will.

So here’s the code you suggested with a stringshape added. I scaled it to 2.0 to see if the text pixelates or not. It doesn’t. Looks great on the canvas. But … how do I save it? This is my sticking point.

Var SavePicture as new Picture(200, 200)
Var r As New RoundRectShape
r.Width = 120
r.Height = 120
r.Border = 100
r.BorderColor = Color.RGB(0, 0, 0) // black
r.FillColor = Color.RGB(255, 102, 102)
r.CornerHeight = 15
r.CornerWidth = 15
r.BorderWidth = 2.5

Var ss as new StringShape
ss.Text = “Hello”

SavePicture.Graphics.DrawObject(r, 100, 100)

g.DrawPicture(SavePicture, 0, 0) // Draw SavePicture in the Canvas
g.ScaleX = 2.0
g.ScaleY = 2.0
g.DrawText (ss.text, 50, 50)

It’s on the same page:

Var file As FolderItem
If TargetMacOS Then
  file = FolderItem.ShowSaveFileDialog("", "vector.pict")
 file = FolderItem.ShowSaveFileDialog("", "vector.emf")
End If

If file <> Nil Then
  SavePicture.Save(file, Picture.SaveAsDefaultVector)
End If

When pasting code you should highlighting it and pressing the </> button, or type ``` before and after it.

Well, I tried that many times. Exact code. And still get no file. So could there be a bug in Xojo? I’ve uncovered two of them in my time here.

And yes, I should’ve highlighted the code. My mistake.

You need to make it a zero-depth picture:

Var SavePicture as new Picture(200, 200, 0)

New Picture(200, 200) creates a raster image with depth 32 and transparancy.
New Picture(200, 200, 0) creates a vector image.

Hey, that’s good to know. I’ll try it.

When I do that – new Picture(340, 280, 0) I get a Nil graphics on that picture.



I found something in a former thread that talks about shutting off ‘Supports HiDPI’. In the docs I found that you can only do this through “Shared Build Settings” but I don’t know how to do that.

That’s correct, at that point p is Nil. You need to draw something so p will not be nil after that.