I have an application which persists all data structures to an XML file. Some of the data objects have AWT Images as properties which should be saved to the XML file, too. I use JAXB for the marshalling and unmarshalling process. The binary data are marshalled to base64 encoded text in the XML file and the base64 data are unmarshalled to byte arrays in Java.
For this I need to convert between Images and byte arrays in both directions. I know there are many links on the internet and there are also discussion on JavaRanch but actually I couldn't find any good, working solution. What do you think would be the best idea to convert between Image and byte? Would you store the whole Image as jpg or png to XML or would it be a good plan to store only the raw image data? Perhaps some hints how to do this right?