I'm a newbie to Java and I want to know how to get/put the value
of a pixel. What object and method do I have to use?
--
Pedro Godfroid
Sevilla, Spain
e.g.
import java.applet.*;
import java.awt.*;
import java.awt.event.*; // for MouseListener
public PixelTest extends Applet implements MouseListener {
int x,y;
public void init() {
addMouseListener(this);
}
public void paint(Graphics g) {
g.drawLine(x,y,x,y); // draw pixel
}
// You have to include all five of these methods
public void mouseClicked(MouseEvent me) {
x=getX();
y=getY();
repaint();
}
public void mousePressed(MouseEvent me) {;}
public void mouseReleased(MouseEvent me) {;}
public void mouseEntered(MouseEvent me) {;}
public void mouseExited(MouseEvent me) {;}
}
In article <MPG.12e90c79e...@news.eintec.es>,
--
Sundar Dorai-Raj
Department of Statistics
Virginia Tech
sdor...@vt.edu
Sent via Deja.com http://www.deja.com/
Before you buy.
Sundar <sdor...@vt.edu> wrote in message news:85nges$tn$1...@nnrp1.deja.com...
------
Posted via news://freenews.netfront.net
Complaints to ne...@netfront.net
> public PixelTest extends Applet implements MouseListener {
> int x,y;
> public void init() {
> addMouseListener(this);
> }
>
> public void paint(Graphics g) {
> g.drawLine(x,y,x,y); // draw pixel
> }
>
That's a line from a point to the same point. Is there not any
simple Put Pixel method?
> // You have to include all five of these methods
> public void mouseClicked(MouseEvent me) {
> x=getX();
> y=getY();
> repaint();
> }
> public void mousePressed(MouseEvent me) {;}
> public void mouseReleased(MouseEvent me) {;}
> public void mouseEntered(MouseEvent me) {;}
> public void mouseExited(MouseEvent me) {;}
> }
>
That's not exactly what I want. I want to know the RGB value of a
particular pixel of an image, not where the mouse is.
Thanks a lot
--
Pedro Godfroid
Sevilla, Spain
PS: By the way, that's my daughter newsreader...
http://www.cs.bell-labs.com/who/wadler/pizza/gj/
http://java.sun.com/products/jdk/1.2/docs/guide/collections/
int pixels = new int[width * height];
PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0,
width);
try {pg.grabPixels();}
catch (InterruptedException e) {}