byte[] to Image

C

Chris Smith

How do I convert a byte[] to an Image object?

If it's in a format that is implemented by the default toolkit
implementation, then you call:

Toolkit.getDefaultToolkit().createImage(myByteArray);

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

SPG

Hi,

You could use the ImageIcon implementation, which takes a byte[] as a
contructor param.
Failing that use an ImageInputStream

HTH,

Steve
 
B

Boudewijn Dijkstra

How do I convert a byte[] to an Image object?

Use a java.awt.image.BufferedImage. The simplest would be to call
setRGB(int, int, int) on a newly created BufferedImage for every pixel in
the array.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top