I am using the following code to save an image created on a Form to a bitmap file:
SavePicture Form1.Image, Output_Dir + Patternname + ".bmp"
DoEvents
Now the image created on the form is a 1600×1200 pixel image (which looks correct);
however, when I save the file using the above code the image is always saved as a 1920×1200 pixel bitmap.
1920×1200 is the current resolution of my screen.
Here is the code used to set the width/height of the form image:
Form1.ScaleMode = vbPixels
Form1.AutoRedraw = True
W = 1600
H = 1200
Form1.Width = W * Screen.TwipsPerPixelX
Form1.Height = H * Screen.TwipsPerPixelY
Form1.Show
I cannot seem to understand why the form image looks correct at 1600×1200, yet when I save the program adds an extra white block of 320X1200 to make the bitmap 1920×1200.
I see you’re setting the size of the form Form1. You need to be changing the size of a picturebox on the form. Make sure you have a PictureBox control (“Picture1”) on your form, and try this:
Then save it with this: