I have two questions:
1) I have a PictureBox
and its Dock is set to Fill. When I resize the Form
I cannot create a Graphic on the part of the PictureBox
that is extended. What is the problem?
2) I want to convert the Graphic that is created on the PictureBox
to Bitmap
and save it as
*.JPG or *.bmp. How can I do this?
You create them by taking pictures with a camera, capturing a desktop screenshot or saving a file in an image-editing program. Most image editors have an option to save files in BMP format, a lossless compression format similar to TIFF and appropriate for high-detail, offline work.
A Bitmap is an object used to work with images defined by pixel data.
you can use the handle device to get the bitmap out of the picture box
Graphics g = pictureBox1.CreateGraphics();
Bitmap bitMap = Bitmap.FromHbitmap(g.GetHdc());
bitMap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
or even better, if the pictureBox does`nt modify the image, you can directly get the image from the pictureBox control
pictureBox1.Image.Save("path", System.Drawing.Imaging.ImageFormat.Jpeg);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With