mfc >> Erase a line in CBitMap

by lynnzyeo » Tue, 21 Mar 2006 19:46:22 GMT

Hi, got a problem here. Say I have drawn a yellow line on a black
background cbitmap. The background of the bitmap will have some grids,
which are blue. Is there any way to erase the yellow line such that the
grids are unaffected? Any ideas? Thanks in advance.



mfc >> Erase a line in CBitMap

by Ajay Kalra » Tue, 21 Mar 2006 22:28:56 GMT


I dont think this is possible at GDI level. Ultimately its all pixels.
If you have this line as an object, you can put some methods in it
which erases the object by XORing etc. If you are using OpenGL/DirectX
etc, there may be some methods to do it as well.

--------
Ajay Kalra
XXXX@XXXXX.COM




mfc >> Erase a line in CBitMap

by AliR » Tue, 21 Mar 2006 23:57:17 GMT

If you want to allow users to deleted some drawings after they have been
drawn, you will need to keep your drawings as objects instead of directly
drawing to the DC as the user draws.

For example. You will need to have a class for everything that you allow the
user to draw (Rectangles, Circles, lines,....)
As the user draws, you need to create one of these classes and store it in
an container class (array works well, if you care about zorder). When you
need to redraw the graphics, loop through the container, and tell each one
to draw itself. When you want to delete an item (like a line) simply remove
it from the list, and redraw the screen.

AliR.







Similar Threads

1. Need to erase separator line on gradient panel

In my WinForms app I'd long ago implemented a drag & drop mechanism just like 
is used in PowerPoint when one wants to rearrange the order of the slides.  
Specifically, a thin black line is shown between thumbnails to indicate where 
an item will be dropped.

As the user moved away I'd erase it by simply drawing another line using the 
BackColor of the panel.  This worked great!  But I've recently switched to 
using a Gradient panel and so now the BackColor no longer applies.

Can anyone recommend how I should erase the thin black line now?

-- 
Robert W.
Vancouver, BC
www.mwtech.com

2. How to erase a line by drawing on top

3. Erase a line by LineTo() & SetROP2()

By calling the following function twice, I can erase a line drawn before.

DrawOrEraseLine(HDC hDC)
{
     SetROP2(hDC, R2_NOT);
     MoveToEx(hDC, 10, 10, NULL);
     LineTo(hDC, 100, 100);
}

The problem is that I can NOT specify a color for the line. Is there a way
to draw a specified color line with the first call and to erase it with the
second call by LineTo() & SetROP2() function?

Please help.

William

4. erase line

5. Erasing a List View's items, without erasing the columns

Hi,

I have a list view that will be update dynamically when new
information is received.  I parse through the information and call the
update function to clear the current items that are in the list and
print out the new data.  My problem is that I dont see a function that
will only clear out the items and subitems and not the columns.  Does
anyone know of a function that does that?

Thanks.

MJ

6. erase vs. erase

7. vector<>.erase(where) vs vector<>.erase(from, to)

8. How to read a text file line by line and remove some line