?
Solved

Image Eraser algorithm?

Posted on 1997-10-22
5
Medium Priority
?
491 Views
Last Modified: 2008-03-10
Hi. I am trying to learn Java. I am attempting to write an image processing application. I want to be able to dynamically erase selected areas of a .gif or .jpg image with the drag of the mouse. So far, I have been able to make the entire image transparent in one fell swoop using an image consumer (Java's PixelGrabber class )to place all the image's pixels into an array and then recreating and filtering each pixel with an image producer (MemoryImageSource class).

I have tried placing the relevant "make transparent" code inside the mousedrag event handler method with no luck. What am I overlooking? Please does anyone know of an algorithm that does this sort of thing? I'm not asking for 'working code' - that would take the fun out of it for me. Just a relatively self-explanatory algorithm would be most appreciated.

TIA
0
Comment
Question by:wboyd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:gnawed
ID: 1229394
Hmm, might be easier and faster to draw the image to an offscreen buffer, then draw over the offscreen image with a "brush" that is the same color as the background during the mouseDrag() and then blip the offscreen image onto the screen.
0
 
LVL 2

Author Comment

by:wboyd
ID: 1229395
Thanks gnawed for your answer. However, I'm afraid I can't accept it. I should have mentioned that I've done it that way in other excercises and you are correct - it is easier. I suppose it's more a matter of my curiosity about how to get the same sort of effect but using PixelGrabber and MemoryImageSource. In fact I've had some hopeful results in the past doing what you're suggesting drawing the transparent MemoryImageSource to an off-screen graphics context, etc. I should also add that there will be another .gif/.jpg image as the background onto which the erased image (foreground)  will be overlaid. So, I wanna erase the top image and leave (or at least appear to leave) the background image intact.
0
 
LVL 4

Accepted Solution

by:
rembo earned 600 total points
ID: 1229396

You can still do this without doing MemoryImageSource and
PixelGrabber.  PixelGrabber is painfully slow and it will
never run smoothly.  I have something that does exactly
what you're trying to do, and I'd be happy to mail you
the source using offscreen buffers and Images, but
not the PixelGrabber.  If that's acceptable, just give
me your e-mail and I'll send it to you.

-Tony

0
 
LVL 2

Author Comment

by:wboyd
ID: 1229397
Thanks Tony, for your answer. As I mentioned in my earlier comment to gnawed, I have already written some code that does what I want using offscreeen buffers and images as you are suggesting. I was curious to figure out how to do it using PixelGrabber and MemoryImageSource. Nevertheless, although I did orignally say I wasn't requesting working code, your offer might at least be helpful to compare the logic you used with what I've used.  Even though you say PixelGrabber is slow, etc. as long as you're sending the other stuff can you also please send an explanation of how you understand it would be done with PixelGrabber anyway? I need to learn the hard way :-) My email address is wboyd@clara.net Or, if that doesn't work zp374@city.ac.uk is my address at school. Thanks.
0
 
LVL 4

Expert Comment

by:rembo
ID: 1229398

I apologize for the delay as I was out of town and couldn't
access my system.  I have e-mailed you the files.  If you
have any trouble with them at all, please let me know, and
I'll put them up on my site for you to access them.

Hope that helps,

-Tony

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question