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.
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.
expectation is the root of all heartache - shakespeare. tiny ad: