users@jaxb.java.net

RE: Image as Base64

From: Markus Karg <karg_at_quipsy.de>
Date: Mon, 21 Mar 2011 14:47:40 +0100

I didn't say that a PNG shall be transferred as a JPG; actually at time of marshalling I do not know the disk format of the source file but just have "some" java.awt.Image of unknown source. Exactly it was what I wanted to know: What data format is transferred now, if I do not do anything particular?

 

So if I understand correctly:

 

* Without @XmlMimeType the transferred bytes are of what format? Since java.awt.Image has nothing like "getBytes", what does JAXB actually do to get the (originally PNG) bytes?

 

* With @XmlMimeType the transferred bytes are converted to that format? So if I did ImageIO.read(PNG) with @XmlMimeType("image/png") JAXB will apply PNG formatting (even if the java.awt.Image maybe was loaded from a GIF originally)?

 

Thanks!

Markus

 

From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: Montag, 21. März 2011 14:28
To: users_at_jaxb.java.net
Subject: Re: Image as Base64

 

On 21 March 2011 14:13, Markus Karg <karg_at_quipsy.de> wrote:

        Wolfgang,

         

        maybe I am blind, but where on that page does it say that *any* Image (possibly PNGs) will be transferred as JPGs?


Why should a PNG be transferred as JPG? Whatever you have, as a byte array, is transferred. Sender and receiver should have some agreement; xmime:expectedContentTypes is the vehicle for that, resulting in a @XmlMimeType.

-W

 

         

        Regards

        Markus

         

        From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
        Sent: Montag, 21. März 2011 14:08
        To: users_at_jaxb.java.net
        Subject: Re: Image as Base64

         

        See the text (and image!) on http://jaxb.java.net/tutorial/section_2_2_17-Image-Data.html#Image%20Data
        
        If it has a mime type it should be representable, Java processing being available.
        
        -W

        On 21 March 2011 13:49, Markus Karg <karg_at_quipsy.de> wrote:

        I just noticed that JAXB is able to deal with java.awt.Image. Looks like it uses Base64 to inline it. But I wonder what the transferred bytes actuall do present: The raw data of the BufferedImage, or a common file format like JPG, PNG, GIF. etc. (which one)?

         

        Thanks

        Markus