Reputation: 1852
After I've drawn an object in the bitmap, I'd like to move it, so I need to draw the object again in the background colour, before drawing again in the proper colour. Assuming this is the correct approach, how do I find out what the background colour actually is? Thanks, James
Upvotes: 0
Views: 323
Reputation: 3905
Since you have control on the canvas and if you have a "clean" canvas, you can get the color of any pixel before drawing and that should be your background color.
But remember, you don't have a background color on a regular bitmap, just a bunch of pixels! So if your canvas is not clear, or if you don't have a way to get the color before drawing, you have to make assumptions. There a quite a few solutions depending on your requirements. My suggestions are:
Upvotes: 1
Reputation: 180
Once you draw your object you can only use GetPixel to obtain the colour:
Bitmap.GetPixel(x,y)
Why not just clearing the whole bitmap and rewriting your object again? If your bitmap is not extremely large, you won't probably even notice any difference in performance.
Upvotes: 1