Count pixels

T

TheC0der

Hello everybody!
I need to know how many white(or other colors) pixels are in Graphics,
but i didnt found way :(. I see that there is solution for Image, but
this cant help me.
I have one more question - (may be is silly) How to copy Image to
Graphics and Graphics to Image?
Thanks for your attention.
 
I

Ingo R. Homann

Hi,
Hello everybody!
I need to know how many white(or other colors) pixels are in Graphics,
but i didnt found way :(. I see that there is solution for Image, but
this cant help me.
I have one more question - (may be is silly) How to copy Image to
Graphics
g.drawImage();

> and Graphics to Image?

AFAIK impossible. The solution is to create an Image, to get its
Graphics and to paint on this graphics.

Hth,
Ingo
 
J

Josh Falter

Disclaimer: There may be a slick way to do the counting of white
pixels, but off the top of my head I know that java.awt.Robot has a
getPixelColor(x,y) function that you could use if you got desperate.
 
O

Oliver Wong

TheC0der said:
Hello everybody!
I need to know how many white(or other colors) pixels are in Graphics,
but i didnt found way :(. I see that there is solution for Image, but
this cant help me.
I have one more question - (may be is silly) How to copy Image to
Graphics and Graphics to Image?

Think of the Graphics object as a pen, and the Image object as a sheet
of paper. You use the Graphics object to draw on the Image, just like you
use a pen to draw on a paper. However, the Graphic object itself does not
store the picture your drew, just like the pen doesn't store the picture.
The picture is stored on the paper, or the Image object.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top