ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Create an AImage

admin
28 Mar 2008 13:41:08 GMT
28 Mar 2008 13:41:08 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4869489

By: krishna12345

I am having some problems creating an AImage from an array of bytes. I am unsure what exactly the name field should be. I tried jpg but I get an IOException saying unknown format. My code is basically

AImage imageToDisplay = new AImage("jpg", someByteArray);

And the error I get is
java.io.IOException: Unknown image format: jpg

The program I made basically has the user upload a small image and I store it in my Database as a blob. Then using hibernate I pull the image back up and try and store it in an AImage. I can see the image stored fine in my database, just having trouble putting it into an AImage.

admin
28 Mar 2008 13:57:57 GMT
28 Mar 2008 13:57:57 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4869540

By: krishna12345

Never mind I am an idiot. I didn't know you needed to put in a full filename, I called it p.jpg and it doesn't throw an exception.

Only problem now is it doesn't display the image still, just an x.

admin
28 Mar 2008 14:21:25 GMT
28 Mar 2008 14:21:25 GMT


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4869616

By: varan78

I have used AImage numerous times. The correct usage is


1. Create a BufferedImage object
2. Write it to a ByteOutoutputStream using ImageIO 3. use the ByteArrayOutputStream.toByteArray to get the byte array 4. Construct the Aimage from the bytearray
I use ai=new AImage(); ai.setContent("anyname",bytearray)

anyname does not have to be the name of a file.