调整大小并压缩jpeg [英] Resize and compress jpeg
问题描述
我看到 this 一个>捕获屏幕的教程,我做了一些编辑,结果是好的,
但每个图像的分辨率是1366,768
&p我希望它像683,384
但我得到的只是图像的一部分
这是我的代码: p>
private void显示(位图桌面)
{
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);
}
}
这是我的表单:
我想以分辨率为683,384和更低质量的datagridview图像存储。
而不是 g.DrawImage(desktop,Point.Empty);
使用 g.DrawImage(desktop,0,0,bmp.Width,bmp.Height);
并创建位图,如 Bitmap bmp = new Bitmap(683,384);
/ p>
i seen this tutorial of capture screen and i did some edit to it and the result is good,
but the resolution of each image is 1366, 768
and i want it to be like 683, 384
but all i get is part of the image
here is my code:
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);
}
}
here is my form:
i want to store in the datagridview images with resolution of 683, 384 and less qualty.
instead of g.DrawImage(desktop, Point.Empty);
use g.DrawImage(desktop, 0, 0, bmp.Width, bmp.Height);
and create bitmap like Bitmap bmp = new Bitmap(683, 384);
这篇关于调整大小并压缩jpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!