Painting an image from an array[col] [row] [color]

W

Wolfgang

I have an image given as an integer array of column, row, and color,
like

int imageToPaint [ ] [ ] [ ]

....
imageToPaint[col] [row] [color]
....

Color is a 32-bit integer, with the first byte for red, second byte
for green, third byt for blue (last eight bit discarded).

Can anyone suggest a way to paint this image onto a panel?

Thanks,
Wolfgang
Santa Barbara, CA
 
W

Wolfgang

I meant, paint this onto a panel as a JPEG, GIF, BMP, or whatever is
easiest and looks best. The array imageToPaint[col] [row] [color]
was originally derived from a JPG (or GIF, I'm not sure)

Thanks.
Wolfgang
 
R

Ryan Stewart

Wolfgang said:
I meant, paint this onto a panel as a JPEG, GIF, BMP, or whatever is
easiest and looks best. The array imageToPaint[col] [row] [color]
was originally derived from a JPG (or GIF, I'm not sure)

Thanks.
Wolfgang

I have an image given as an integer array of column, row, and color,
like

int imageToPaint [ ] [ ] [ ]

...
imageToPaint[col] [row] [color]
...

Color is a 32-bit integer, with the first byte for red, second byte
for green, third byt for blue (last eight bit discarded).

Can anyone suggest a way to paint this image onto a panel?

Thanks,
Wolfgang
Santa Barbara, CA

I'm not sure what you mean by painting it "onto a panel as a JPEG...", but
if your array contains what I think it does, you can use a BufferedImage and
set pixels individually. You can even work directly with the raster (though
I have no experience with that).
 
M

Marco Schmidt

Wolfgang:
I have an image given as an integer array of column, row, and color,
like [...]
Color is a 32-bit integer, with the first byte for red, second byte
for green, third byt for blue (last eight bit discarded).

Can anyone suggest a way to paint this image onto a panel?

First create a BufferedImage from your raw data (like this:
<http://www.geocities.com/marcoschmidt.geo/java-image-faq.html#rgba>),
then call Graphics.drawImage in a paint method (or add that image to a
JLabel).

Regards,
Marco
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top