The default color model for MemoryImageSource is of type ARGB (look at
the javadoc for ColorModel.getRGBdefault) and the
color components are packed into an integer. To get a red image, fill you
buffer with: 0xffff0000.
jeannette
> X-Originating-IP: [139.142.186.171]
> Mime-Version: 1.0
> Date: Mon, 20 Mar 2000 10:39:20 PST
> From: Abel Rauch <[EMAIL PROTECTED]>
> Subject: [JAVA2D] HELP!!!!! displaying array of RGB to screen
> To: [EMAIL PROTECTED]
>
> 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".
===========================================================================
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".