Color of Panel

I'm drawing figures on a panel and i want to save them in vector.Could we get panel color pixel by pixel ? thanks regards
[150 byte] By [CoRNeLiuSa] at [2007-10-2 15:30:58]
# 1

I think you're saying it backwards, or else I'm misunderstanding you... you want to draw them as vectors and then convert to bitmaps to get pixel values, right?

import javax.swing.*;

import java.awt.image.BufferedImage;

import java.awt.image.ColorModel;

import java.awt.*;

public class PixelGrabber {

public static void main(String[] args) {

final int width=100, height=100;

BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB );

JPanel thePanel = new JPanel() {

public void paint( Graphics g ) {

g.setColor( Color.ORANGE );

g.fillRect( 0, 0, width, width );

g.setColor( Color.red );

g.fillOval( 0, 0, width, width );

super.paint( g );

}

};

thePanel.paint( image.createGraphics() );

System.out.println( "top left pixel: " + getRgbString( image.getColorModel(), image.getRGB( 0, 0 ) ) );

System.out.println( "center pixel: " + getRgbString( image.getColorModel(), image.getRGB( width/2, height/2 ) ) );

System.out.println( "bottom right pixel: " + getRgbString( image.getColorModel(), image.getRGB( width-1, height-1 ) ) );

}

private static String getRgbString( ColorModel model, int rgbValue) {

return "rgb: (" + model.getRed( rgbValue ) + ", " + model.getGreen( rgbValue ) + ", " + model.getBlue( rgbValue ) + ")";

}

}

jesse_barnuma at 2007-7-13 14:56:34 > top of Java-index,Desktop,Core GUI APIs...
# 2
Yes that is what I mean. Thanks for your interest...Regards
CoRNeLiuSa at 2007-7-13 14:56:34 > top of Java-index,Desktop,Core GUI APIs...
# 3
Did this example help you solve the problem?
jesse_barnuma at 2007-7-13 14:56:34 > top of Java-index,Desktop,Core GUI APIs...
# 4
Yes that is the solution of my problem.Thanks again
CoRNeLiuSa at 2007-7-13 14:56:34 > top of Java-index,Desktop,Core GUI APIs...