views:

233

answers:

2

I need to make a file format for my software. The data is basic key/value pairs and images. The options are:

1) One XML file that has CDATA tag with binary encoded image files or image files encoded in a RGBRGBRGB or RGBARGBARGBA format.

2) One XML file holding key/value pairs and links to image files. These image files would be packaged with the XML file in a ZIP or TAR

What do you think is the best approach? If either is ok, which one do you think is easier to implement? I am using wxwidgets and the wxImage class has a getData() function that returns an array in RGB format. Would writing this array to XML be easier than base 64 encoding a jpeg/png etc? I've never programatically handled a ZIP file but I know there is a helper class in wxwidgets for this kind of thing.

Any insight is appreciated.

+1  A: 

Why don't you use Open XML Format SDK instead of creating your own? Open XML is what Office 2007 uses for their files (Excel, Word, Powerpoint, etc) and it's basically 2).

Nestor
+3  A: 

Using the Open Packaging Conventions and the Open XML SDK1 as suggested by Nestor would be one option but you could also easily roll your own version of such a format.

In general I would prefer the zipped option as the file size would be significant smaller. XML can be compressed very well and the images won't be expanded.

When using a single XML file with embedded images you would have to use base64 encoding to save your images. The size of the encoded images will be about 1.37 times larger than the original size.

However, a single XML file might have advantages regarding further processing of the document, for example you can use it without additional unzip directly as input document for an XSL transform.

1The OpenXML format is a good example in this matter. Normally, files are stored in a zip package fulfilling the Open Packaging Conventions. However, there is also a single XML file version available, the so-called Flat OPC format (at least in Word 2007) to be used as input/output format for XSLT and other document processing steps.

0xA3