Solved

Image Eraser algorithm?

Posted on 1997-10-22
5
483 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 200 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jsp login check 12 67
eclipse console opening separately 2 50
Is Applet the way to go for my drag and drop system? 8 51
Where to place postgres JDBC driver jar on tomcat 8 71
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

751 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