2014-03-05 159 views
0

我看到this教程捕獲屏幕和我做了一些修改它,結果是好的,調整大小和壓縮JPEG

但每個圖像的分辨率是1366,768

enter image description here

我希望它像683,384

enter image description here

,但我得到的是圖像的一部分

enter image description here

這裏是我的代碼:

private void Display(Bitmap desktop) 
{ 
    if (desktop != null) 
    { 
     Bitmap bmp = new Bitmap(1366, 768); 
     using (Graphics g = Graphics.FromImage(bmp)) 
     { 
      g.DrawImage(desktop, Point.Empty); 
     } 

     MemoryStream stream = new MemoryStream(); 
     Image myImg = (bmp as Image); 
     myImg.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); 
     byte[] pic = stream.ToArray(); 

     ssWithMouseViewer.Image = myImg; 
     dataGridView1.Rows.Add(pic); 
    } 
} 

這裏是我的形式:

enter image description here

我想在DataGridView圖像存儲與683,384和分辨率質量較差。

回答

0

代替g.DrawImage(desktop, Point.Empty);使用g.DrawImage(desktop, 0, 0, bmp.Width, bmp.Height);

,並創建位圖像Bitmap bmp = new Bitmap(683, 384);

+0

啊哈,謝謝。 –