Reputation:
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 1600x1200 pixel image (which looks correct); however, when I save the file using the above code the image is always saved as a 1920x1200 pixel bitmap.
1920x1200 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 1600x1200, yet when I save the program adds an extra white block of 320X1200 to make the bitmap 1920x1200.
Upvotes: 1
Views: 1850
Reputation: 697
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:
Picture1.ScaleMode = vbPixels ' Set scale to pixels.
Picture1.AutoRedraw = True ' If needed
Picture1.Width = W ' in pixels
Picture1.Height = H ' in pixels
Then save it with this:
SavePicture Picture1.Image, Output_Dir + Patternname + ".bmp"
Upvotes: 1