可以System.Drawing.Image tImg;
tImg = new Bitmap(20,20,System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Graphics gp = Graphics.FromImage(tImg);
Rectangle r = new Rectangle(-10,-10,30,30);
gp.DrawImage(pictureBox1.Image,r);
tImg.Save("d:\\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
tImg = new Bitmap(20,20,System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Graphics gp = Graphics.FromImage(tImg);
Rectangle r = new Rectangle(-10,-10,30,30);
gp.DrawImage(pictureBox1.Image,r);
tImg.Save("d:\\test.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
解决方案 »
- 没有注册类别 (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
- 关于Base64编码不足3倍数用=号代替
- C# cmd命令
- 急 急!关于datagridview中DataGridViewTextBoxColumn问题
- (请用过memcached集群的兄弟解惑)添加或移除memcached时,memcached客户端该怎样处理而不会影响客户端实例中的其它server
- C#读取XML指定节点
- <%#FormatType((int)DataBinder.Eval(Container.DataItem,"ResourceType"))%> 中FormatType 怎么使用
- 怎么用C#从RSS中读取图片?
- sql update 问题
- 微软专家救命:c#编译器bug,程序停止不动
- 开始学C#了,各位高人帮忙推荐几本E文的经典书籍!谢谢
- 讨论].net中安全问题
//获取原始图片
Bitmap bitmap=new Bitmap(Application.StartupPath +@"\pretty1.jpg");
//设置范围
Rectangle r =new Rectangle(10,10,20,20);
//创建剪切后的Bitmap对象
Bitmap bitmap1=new Bitmap(20,20);
Graphics g1=Graphics.FromImage(bitmap1);
g1.DrawImageUnscaled(bitmap,r);
bitmap1.Save(Application.StartupPath +@"\p2.jpg");
{
System.Drawing.Bitmap Bmp=new Bitmap(Width,Height);
for (int i=0;i<=Width-1;i++)
{
for (int x=0;x<=Height-1;x++)
{
Bmp.SetPixel(i,x,img.GetPixel(scrX+i,scrY+x));
}
}
return Bmp;
}