Implementing floodfill and getpixel
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, April 25, 2001 12:01 PM

I'm implementing a paint application using swing, and I've completed
all the needed functions except floodfill and getpixel. Since Java
does not have either of these functions in the graphics or graphics2d
package how do I implement these?

Thank you

Re: Implementing floodfill and getpixel

Posted By:   Finlay_McWalter  
Posted On:   Tuesday, June 12, 2001 06:09 PM

Keep the image of your screen in an
offscreen image (i.e. one you created with Component.createImage). Then use java.awt.image.PixelGrabber to obtain a pixel array corresponding with the pixels of your image.

You can implement getPixel by examining the array the PixelGrabber made.

You an implement floodfill in the pixel array. Then you need to turn the pixel array back into an image - use java.awt.image.MemoryImageSource to do this.

About | Sitemap | Contact