Bart
Bart

Reputation: 767

C# Removing a certain line in Graphics/Drawing

Is it possible to remove some lines in my graphic panel without erasing the rest?

PanelGraphics.Clear(Color.Black); erases all the graphics but I only want to remove one line, or a certain color.

Is this possible?

Upvotes: 1

Views: 1589

Answers (1)

György Kőszeg
György Kőszeg

Reputation: 18013

Is it possible to remove some lines in my graphic panel without erasing the rest?

Not really. The Graphics does not tell you anything about the actual context, it can be the screen, a printer, a bitmap, a metafile, the surface of a control or something similar. If you draw a Panel or a control you must always re-draw the whole content once it is invalidated. Otherwise, you will get a messy result. Just try to move your window partly out of the screen, the custom-drawn content will be "erased" unless you redraw it.

However, if you have a concrete image, such as a Bitmap, you can replace its colors; however, you must know the exact PixelFormat of the image. See my answer here if you are interested: https://stackoverflow.com/a/33562891/5114784

Upvotes: 2

Related Questions