Picture save doesn't work anymore

Hi,

The code below has been working for years in several apps. I tried to compile my app yesterday to find out it’s crashing every time now. I guess it’s going to cocoa.
Any clue on what I should change?

[code] dim f As folderItem

f=getsaveFolderItem(“PNGf”, “CAO”)
if f <> nil then
p.Save(f,p.SaveAsDefaultVector)
else
return
end[/code]

Thanks

Chris

I’m a bit confused.

You want to save as PNG but use SaveAsDefaultVector which according to the documentation for pucture is PICT on Mac (PICT is no longer default on Cocoa if I’m not mistaken) and EMF on Windows?

Maybe try SaveAsPNG instead?

The documentation entry for picture needs an overhaul, btw.

p.Save(f, Picture.SaveAsDefaultVector)

Right, SaveAsDefaultVector is a class constant of the picture class.

PICT is deprecated by Apple years ago. Probably no longer supported, so Xojo has no vector format on Mac OS X.

Picture.SaveAsDefaultVector = TIFF

Does it mean you cannot save a group2D object through a picture anymore?
It was working for me for years with carbon. I could then open it with illustrator.
Picture.saveasdefaultvector crashes too and saveaspng also.
Do you have any solution to generate a file that I could open with illustrator?

Thanks

Chris

[quote=167652:@Christophe Blanc]Does it mean you cannot save a group2D object through a picture anymore?
It was working for me for years with carbon. I could then open it with illustrator.
Picture.saveasdefaultvector crashes too and saveaspng also.
Do you have any solution to generate a file that I could open with illustrator?[/quote]

PIC no longer works in Cocoa. Png should though.

SVG seems to be the most commonly accepted format and is supported by Illustrator. See the method posted by Dr. Brian Gaines :
https://forum.xojo.com/1819-svg-support?search=Dr+Brian+R+Gaines+

thanks, sounds like a good solution.
Let me try and I let you know

Chris

Haven’t tried (not at my Mac) but have a close look at the documentation:

Note that this value of 100 generates an UnsupportedFormatException. Use value 200 instead (there is no constant for this) if you must save as PICT format on OS X.

So do

p.Save( f, 200 )

Thanks a lot for spending time on the documentation.
I tried p.Save( f, 200 ) but it also crashes.

Chris

[quote=167663:@Markus Winter]Haven’t tried (not at my Mac) but have a close look at the documentation:

Note that this value of 100 generates an UnsupportedFormatException. Use value 200 instead (there is no constant for this) if you must save as PICT format on OS X.

So do

p.Save( f, 200 )[/quote]

It works. Blue is a picture dragged into the project :

[code]Sub Action()
Dim f As FolderItem
If blue <> Nil Then
// Get a temporary file to save the image to
'If Picture.IsExportFormatSupported(Picture.Format) Then
f = SpecialFolder.desktop.Child(“TempImage.pict”)

// Save the image out to the file
blue.Save(f, 200)

End If
End Sub
[/code]

The resulting file is opened by Preview fine. Photoshop no longer recognizes Pict, and I do not have Illustrator, so I could not test.

That said, I have no idea what p is in the OP posts.

P is a picture with an Group2D object associate to it and it clashes.
I will try the SVG solution or print the Group2D and use the save as PDF from the Mac.
I’ll try this tomorrow
Thanks to all of you for your help

Chris

Maybe you could post a simple project with one of your pictures. Would surely make it easier to come up with a solution.

I am using this work around and it’s working fine.
I print the Group2D object and use the Mac save as PDF function or open in preview and save as PDF.
I can then open the PDF with illustrator as a vector graphic. See code below

[code] dim ps As new printerSetup
dim g As graphics
Dim settings as String

ps.maxVerticalResolution=300resop
ps.maxHorizontalResolution=300
resop

If ps.PageSetupDialog() Then
settings=ps.SetupString
End If

g=openPrinterDialog(ps)
if g=nil then
return
end

d.scale=sc0.25resop
g.DrawObject(d)
[/code]

Thanks

Chris