Hi, I am working on Java2D and making some image filters using classes like ImageFilter etc. Now For simple filters I want to get the progress status while the filtering is in progress, so that I can show a progress bar in the GUI. For this I do not have much idea. I think we can use the ImageConsumer interface, so that if the class implementing that interface list itself as an image consumer with the filter operation, it can get the progress with the setPixel method of ImageConsumer interface. Here is two way I have tried implementing this:
2nd way, let�s say we use a smooth filter and replace the processImage(..) method above with the one below (the other methods being same):
Now I do get a progressPercent. But when the percent is 100%, the destimage does not return, that means the operation is not yet complete.
Also I extended the ImageFilter class and over-rode its setPixel method as:
I observe that the setPixel method of MyImageFilter is called several times even for the same scan lines, and even after percentProgress is 100%, the process runs again for 2-4 times. So the filtering operation scans the lines several times to finally perform the filtering, and as such the percentProgress is incorrect.
Can anybody guide me. Is this approach okay and needs to be modified a bit, or there is a different approach to obtain the progress from a filter operation? I think if anyone has done it before, he/she can answer it properly. But ofcourse all suggestions are welcome. I would finally want the same progress from other operations like LookupOp, ConvolveOp, AffineTransformOp, ColorConvertOp, RescaleOp. BTW, can ImageObserver class be of use in this regards? Thanks in advance Tanveer
[ July 26, 2004: Message edited by: Tanveer Rameez ] [ July 26, 2004: Message edited by: Tanveer Rameez ]
Author of JPhotoBrush Pro (www.jphotobrushpro.com)
subject: Getting progress of Image filter operation (FilteredImageSource/ BufferedimageOp)