I am making an application in VB.NET that allows a user to highlight some text in images of documents so that the highlights could be saved for future reference, but the original images would not be modified. I figured I can achieve it by creating a graphics out of an image file and allowing the user to draw on that graphics. The problem is – the graphics can not be created from indexed image files, which many of mine are. I am wondering: is it possible to create a transparent graphics surface above an image in a PictureBox control, so that the user could draw on that surface, but it would appear as if he is drawing directly on an image?
Thank you!
(following assumes WinForms)
Actually you can.
To display image, use
.BackgroundImageproperty ofPictureBox, not.Image.Don’t forget to set correct value for
.BackgroundImageLayoutto disable default tiling and keep it in sync with.SizeModeproperty, so that overlay image is properly aligned.After you set image, create an overlay image (assume your
PictureBoxisPictureBox1:Now you can draw on the overlay image.
Alternatively, you can copy your image (draw it to the overlay for example).