Hello,
Is anyone out there monitoring this list????
I want to take an array of ints and display them as an image. I have tried
this in several ways and have gotten gray or block or blue and black
screens. I am just trying to display an all red screen right now. The values
in my array are {255,0,0,255,0,0,255,0,0,255.....}
Sample code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.image.*;
class render1 extends Panel {
int[] buffer = new int[176*144*3];
public void paint(Graphics g) {
MemoryImageSource imageSource = new MemoryImageSource(176, 144,
buffer, 0, 176);
Image img = createImage(imageSource);
g.drawImage(img, 0, 0, this);
}
public Dimension getPreferredSize() {
return new Dimension(176, 144);
}
public void bufferChange(int x, int y) {
for (int z = 0; z < 176 * 144; z+=3) {
buffer[z] = 255;
buffer[z+1] = 0;
buffer[z+2] = 0;
}
this.repaint();
//sleep(1000);
}
public void process() {
int j;
render1 app = new render1();
app.bufferChange(0, 0);
JFrame f = new JFrame("dsfhsdhfdj");
repaint();
WindowListener wl = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
System.exit(0);
}
};
f.addWindowListener(wl);
f.getContentPane().add(app);
f.pack();
f.setVisible(true);
app.bufferChange(0, 0);
}
}
What am I doing wrong?
Thank you,
Abel.
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".