views:

56

answers:

1

I'm just starting out with my first Adobe Air project (I'm a pure AS3 developer by trade). I'm planning to build an image editor which supports layers. I'm wondering what the best way would be to store an entire project including layer data (images) to a users hard disk.

I'm wondering if there is any pros/cons in creating a custom file format for my application. The idea is I will be able to store an entire project in a single file. This will be done by writing meta data to the file's header such as the image dimensions, layer names, layer data offsets etc...

I'm trying to be mindful of the issues which might arrise such as maintaining backwards compatibility after adding new project features/meta etc.

I guess I'm asking whether people have any advice or experience with creating a custom file format for Adobe Air and if there are any other 'out-of-the-box' solutions to saving 'complex' data to a users hard disk.

Thanks.

+1  A: 

Probably you could do a custom binary format and write the ByteArray to disk. That should be fast and compact. I've never wrote a custom binary format, but I'm sure someone here can walk you through the best practices in that. You could save a string description of your layer's arrangements to a ByteArray using writeUTF or writeUTFBytes and you can use BitmapData's getPixels() as it returns a ByteArray.

A 'workaround' idea that comes to mind is to create an archive uzing an as3 zip package that will contain your layers as PNGs/JPEGs (probably using the image as3corelib encoders) and an xml file that describes your file(what layers should go where, with what blend/transparency/etc. ). This might be bit longwinded though.

HTH, George

George Profenza