File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Erase / Image / Canvas?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Erase / Image / Canvas??" Watch "Erase / Image / Canvas??" New topic

Erase / Image / Canvas??


Joined: Apr 13, 2001
Posts: 2
I want to create an applet which loads an image as background and
have an option to draw anything on the image (image is not changeing , think that there is a sub layer containing the image and an upper transparent layer which is holding the drawings)
And One important thing is I want to be able to erase any part of the drawing without touching any pixel of the image on the sub layer...
So you can think as:
1. A Sub Layer containing an Background image
2. A Transparent Layer on the Sub Layer which gives you the drawing options... And an eraser function which can erase the drawings without eraseing the background image....
Is that possible? how?? Its very important.. I couldnt find any answers...
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

I'm not sure if you can do that or not. The closest I have come to doing anything like that is in html I had a transparent annimated gif with a .jpg behind it.
I hate to say this but, your name does not comply with the Javaranch naming guidelines which can be found at
please register again with a valid name.

Visit my download page

Joined: Apr 13, 2001
Posts: 2
Sorry for my nick.. I will change it.. But I solved the problem Maybe you are interested in such a case...
Well First You need to Set the background with
g.drawimage(Image img,int x, int y, this);
For drawing the image you want as background...
And for the drawing part you can use any method of the
Graphics.... g.DrawOval etc...
The Tricky part for the Erasing and Not touching the background is Like Repainting the Background on the Pixels which erase should be done.. So you take a Portion of the real image and replace the part on canvas which should be erased with that portion of the image...
Graphics g = getGraphics();

Here we go ) If you need more info I can send the source code of the applet..
Have a nice day..
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Erase / Image / Canvas??
jQuery in Action, 3rd edition