tags:

views:

63

answers:

2

I want to implement a rubber function just like photoshop, but I hope the rubber just to erase the shapes that drawed on background without modifying the background. Now the background is a image so I can't use the brush with the single color.

+1  A: 

You need to store each layer of the image in its own buffer, and then combine them to output it. So the background would be in one Image object and the shape would be in another Image object. When you get the WM_Paint message, you would have to combine both images into one and output that (or you would have to have the images pre-combined in a third Image object in memory).

Dave Markle
A: 

If you just want to draw simple lines/shapes like a rubber-banding box, the old-fashioned way is to use exclusive-or painting. This "inverts" the colours where it is drawn, so drawing the same shape a second time erases it and returns the original image.

These days computers are much more powerful so we tend (as Dave Markle has said) to just combine two separate images onto the screen (you just have to store the actual image you are editing in an offscreen bitmap). This allows you to draw the overlay using any colour/transparency, so you can make it look much nicer.

Jason Williams