Cyotek.Windows.Forms.ImageBox
Cyotek.Windows.Forms.ImageBox copied to clipboard
How to save viewport as bitmap?
Hi, i am overriding OnPaint and draw an overlay on my image.
Can I Somehow save that whole construct of Image + Overlay in a .BMP file? When I use DrawToBitmap it renders only the visible part, but i want the whole part.
Hello,
I probably wouldn't do this from OnPaint
as this event can be frequently called and could slow your application down if you put expensive code in it.
You could probably use something similar to the following to create a copy of the source image, apply your custom overlay, and then save it to a file.
using (Bitmap copy = new Bitmap(imageBox.Image))
{
using (Graphics graphics = Graphics.FromImage(copy))
{
// draw overlay
}
copy.Save(@"t:\temp\copy.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
Hopefully this gives you a starting point!
Regards; Richard Moss