Can the output from Graphics.CopyFromScreen scale up to A4 size?
The following code outputs the screen to a JPEG. When printed on A4 , it hardly occupies half the height. Can it be made to scale up to 827 x 1169 i.e A4 size ?
Thanks, Chakra.
public void TakeScreenshot()
{
Rectangle bounds = Screen.PrimaryScreen.Bounds;
using (Bitmap bmp = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb))
{
using (Graphics gfx = Graphics.FromImage(bmp))
{
gfx.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy);
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "jpeg files (*.jpeg)|*.jpeg";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
开发者_运维问答 // Code to write the stream goes here.
bmp.Save(myStream, ImageFormat.Jpeg);
myStream.Close();
}
}
}
}
}
You probably need to adjust the dpi of the image in some way to stretch it up to the size of a A4
精彩评论