coloring between the lines

hello,

i am having a problem figuring out something out in java. i have to write an app that has the outline of a human body that nurses will "color" certain areas. then i need to calculate what percent of what area was colored( left arm, right arm, etc).

i have the body outline in the form of an .png. i can load the image, copy it to a BufferedImage, render it and draw it back to the screen. the image consists of an all white body with a black outline, on a tan background,

problem #1) i can't seem to find a way to keep the the painting inside the black outline of the body. any suggestions on how to approach this?

problem #2) any advice on calculating the percentage of each area colored would be appreciated.

thanks.

[767 byte] By [rswa] at [2007-10-2 13:46:09]
# 1

When you're drawing, it should be easy enough to check the pixels you're drawing on, and if they're not white, don't draw. I don't have the API in front of me so I can't tell you how to do that..

I'm not sure how big your image is, but if it isn't huge, it would probably be fast enough to loop through each pixel, check the color and calculate a percentage that way.

jgoulda at 2007-7-13 11:43:34 > top of Java-index,Java Essentials,Java Programming...
# 2
the image isn't that big at all. excellent idea. i will see how to check the color of the pixel. thank you.
rswa at 2007-7-13 11:43:34 > top of Java-index,Java Essentials,Java Programming...