This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 41181
    
  45
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Gray scale unformatted images
 
Similar Threads
Image processing
Drawing Canvas
Structure Size
Draw Image Off-Screen
how to get pixel value of each pixel of a gray-scale or black-white image?