tags:

views:

19

answers:

1

Hi,

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();
                   }
               }
             } 
          } 

    }
A: 

You probably need to adjust the dpi of the image in some way to stretch it up to the size of a A4

Fredrik Leijon
Ok but that would reduce the quality of the image is it not ?
Chakra
yeah, it would result in lower quality on paper since you have to scale the source
Fredrik Leijon