Create a buffered image from rgb pixel values?

Try setDataElements instead of setPixels. Another option is for the image to share the array instead of copying from it (see this answer for an example. ).

1, cool, I learned the difference between setDataElements and setPixels. – camickr Jan 6 at 18:08 I tried setDataElements, but I still get the same problem. I have added an image of what I'm seeing.

Maybe it will give a hint into what might be causing it. – Jeff Storey Jan 6 at 18:12.

Not sure how to do it with a single array value. I believe you need three array values to specify the color when you use TYPE_INT_RGB: import java.awt. *; import java.awt.image.

*; import javax.swing. *; public class ImageFromArray2 extends JFrame { int width = 50; int height = 50; int imageSize = width * height; public ImageFromArray2() { JPanel panel = new JPanel(); getContentPane(). Add( panel ); int pixels = new intimageSize * 3; // Create Red Image for (int I = 0; I Add( createImageLabel(pixels) ); // Create Green Image for (int I = 0; I Add( createImageLabel(pixels) ); } private JLabel createImageLabel(int pixels) { BufferedImage image = new BufferedImage(width, height, BufferedImage.

TYPE_INT_RGB); WritableRaster raster = image.getRaster(); raster. SetPixels(0, 0, width, height, pixels); JLabel label = new JLabel( new ImageIcon(image) ); return label; } public static void main(String args) { JFrame frame = new ImageFromArray2(); frame. SetDefaultCloseOperation(JFrame.

EXIT_ON_CLOSE); frame.pack(); frame. SetLocationRelativeTo( null ); frame. SetVisible( true ); } }.

TYPE_INT_RGB uses a single int per pixel; OP specifies that each element of the int has an RGB value. – Michael Brewer-Davis Jan 6 at 17:51 @MIchael Brewer-Davis, you would think that TYPE_INT_RGB uses a single int per pixel unit, however that does not appear to be the case when using the setPixel(...) method, which is why the question was asked. I provided a solution that shows how to use the setPixel(...) method.

Having said that, the best answer is to use the setDataElements(...) method. – camickr Jan 6 at 18:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions