Does Vector Graphics in Xojo only refer to the process of creating bitmap pictures using Xojo vector methods, or does it also mean that Xojo stores the information used to create the bitmap as is done in a PICT or SVG document?
I think it’s the former because I can’t find evidence of the latter in the debugger, but after seeing the “OpenVector” Picture — Xojo documentation, method I thought I should ask to be sure that when a picture is loaded from disk, the vector objects will not be included.
From a quick test of opening a SVG file using openVector and then drawing it at 32x32 256x256 5000x5000 you can clearly see that the vector information is being used to render each time.
Embedding as a resource does not do this. It takes a render of it at 512x512.
No I wrote it because I don’t know if Xojo’s Save function will write out vector graphics back to an SVG file. My knowledge of the SVG format, which is none, is meaningless. I tried it, didn’t work, looked at the other link and saw it might only work with very old formats, so I assumed it cannot be done.
I am just trying to help answer the original poster’s question. Having a go at me for not knowing how SVG’s work helps no one.
I’m trying to discover if Xojo has a preservable vector format. There is much in the documentation indicating it is possible to save a vector graphic, but so it looks like the answer may be that it does not.
This last attempt is pieced together from the docs. It gets as far as creating the vector Picture, from which the objects that created it can be retrieved (eg, myPic.Objects.Item(1)).
But, in the step to save the Picture to disk, the Vector format is not supported, so the vector info can’t be preserved. p.Save(file, Picture.SaveAsDefaultVector) ' ERROR: This format is not supported
… or I’m not doing something right. TestVector.zip (5.7 KB)
This is the page in the documentation that talks about vector saving. On Windows it offers EMF and on Mac Pict. As far as I know both formats are pretty much extinct. Apart from SVG, which has been discussed there is also PDF graphics, which can be vector based.
EPS is ‘old’ but still supported by things like MS Word (at least on Mac, but I’m pretty sure Windows also).
SVG is supported on web pages but doesn’t work none graphic editing programs, such as MS Word. For Xojo there’s currently no load or save.
PDF can be used to save your 2D vectors but not opened again. Putting a PDF graphic in a HTML page is somewhat overkill, but should work. There does seem to be some support for dropping PDF into the likes of MS Word but it’s not great.
There are plenty of other formats but they tend to be proprietary, such as Illustrator format (AI). I used to create logos in Illustrator and use them in letter heads in Word. Perfect printing no matter how good your printer. I used EPS to export the files into something MS Word would use.
My main focus now is to get graphs out in a vector format, preferably something that can be displayed in a web browser and copied and pasted into the likes of Word. The UTF8 problem prevents me using build in graphs and PDF, but I’ve my own engine for SVG graphs. The issue is you can’t copy and paste them from HTMLViewer in any useful way.
Indeed, but it is the latest information. There’s nothing better in the docs.
Yes, I mean Xojo created. I wasn’t responding to you about PDF and I can’t afford plugins. You can save graphics as PDF, but you can’t use Chinese text (for example).
My suggestion for this would be a PDF with metadata representing the document.
This is exactly how an Adobe Illustrator PDF works when you save it properly: the PDF contains the rendered document, which can be read by a very wide range of programs; and the proprietary Illustrator document data is stored as metadata within the PDF.
When an Illustrator document is saved as the Illustrator PDF format, it renders that document down to a regular PDF file and inserts a proprietary document representation into it as metadata. When Illustrator opens such a document, it reads in the metadata and constructs an in-memory representation of the document. It does not read in the visible PDF data when the proprietary Illustrator document representation is present.
This can lead to some puzzling (and amusing) mischief if a different program edits the PDF and makes visible changes to it (say, swapping a color or editing some text). Viewing the document in a PDF reader will show the edits, but opening it into Illustrator does not, because the other program didn’t edit the Illustrator proprietary document representation.
In our little Xojoworld situation, you might think of your data as a collection of in-memory objects – perhaps an array of Object2D objects. When you go to save this document, you render the graphcs objects into a PDF. Then you serialize your array of Object2D objects and insert it into the PDF as metadata. Later, when your application reads in the PDF, it can extract the metadata and reconstruct the document in memory.
The benefits of this approach are pretty substantial. PDF is a very widely accessible interchange standard, highly flexible, viewable across virtually all platforms and very often embeddable into other applications. It is the format of choice for archiving documents and will be readable for decade and decades to come, as it is so widely deployed. By saving your document as a PDF, you automatically get the advantages of a large and well-developed system of tools designed around the format.
EPS is more than just old, it is hard deprecated. Because it is based on Postscript, it suffers from the limitations of the Postscript imaging model (no partial transparency, no transfer modes) and has long been supplanted by PDF. EPS files contain Postscript code that must be interpreted to be displayed (unless there is an embedded bitmap preview), while PDF is a file format that sidesteps all the complexity of an actual programming language.
If I were still a consultant for creative professionals, I would strongly recommend that any client with libraries of EPS files make plans to convert them to PDF while they can still find the tools to do so.
My other, longer reply suggests an approach used by Illustrator to do just this.
I agree with both of those things. What is missing from PDF is an image format file type that just contains the graphics element rather than the whole document approach of PDF as it currently is. Something that could be used in an HTML image tag, which currently doesn’t work. Having to add a PDF insert into your HTML is a little OTT for just an image. I’m thinking of .EPS vs .PS files. Not that EPS could be used in an image tag. I suppose with modern HTML embed is as easy, I’ve not tried it because of the UTF8 problem.
Emile, that doesn’t really answer the question though. Sure, you can save it to pdf, but that is an inadequate solution, as has been stated several times.
PDF is in no way a format to store vector graphics. SVG exists for that. PDF is the format to store DOCUMENTS. It has a complex structure containing bags of mixed contents, textual, binary, pixels, vectors, glyphs, audio, video, etc.
You just chose one very improper file to deal with this content, but that it is your choice… PDF wasn’t created to be an editable format, even for vector contents. Sure people can a lot of tricks if they want, they can insert even the Harry Potter movie inside one, but surely the market will prefer something standard like MP4 with H.264 in lossless mode to store them and edit later.
And yet it can be. Illustrator has been able to open any print-intended PDF for editing since the late 90s. Editing PDF is a major reason Adobe Acrobat even exists.
I’m not saying it is ideal for all usage scenarios. PDFs often contain text that is difficult to edit, for example. But vectors in a PDF file are stored in a very straightforward format and with a sprinkling of metadata, there’s absolutely no reason it can’t be a round-trip editable document format.