wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Gray scale unformatted images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Gray scale unformatted images" Watch "Gray scale unformatted images" New topic
Author

Gray scale unformatted images

Nate Lockwood
Ranch Hand

Joined: Feb 22, 2010
Posts: 83
I'm really new at Java coming over from C/C++ and know little about GUIs so far. I'll probably use JavaBeans or jEdit for the project I have after I learn more basic java.

For part of the GUI I will need to display an image. The pixels are bytes, that is, one byte is one pixel, and are gray scale. No color bands are encoded in the bytes. I will get the data into a byte array after a little processing but don't see how to create an image from this array and while I've seen some code examples for image display they tend to be color images, formatted such as JPEG, and read from files. I assume that the image will be displayed on a panel.

Can anyone point me to some example code for displaying an array of byte as an monochrome image?

I know that I could probably stuff the bytes into integers so that for each pixel each band/color has the same value but this appears to be overkill.

Thanks,
Nate
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
I'm not sure of the specifics, but this probably involves creating a DataBufferByte object, using that to create a Raster object, and finally creating a BufferedImage from the Raster, probably of type TYPE_BYTE_GRAY.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Gray scale unformatted images