Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Erase / Image / Canvas??

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
Ranch Hand
Posts: 4716
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic