C# GDI画图改变图像大小
private void Create_Validate_Image()
{
System.Drawing.Bitmap validate_image = new System.Drawing.Bitmap(width, height);
System.Drawing.Image image11 = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Request.MapPath("42.jpg"));
var image112 = image11.GetThumbnailImage(image11.Width / 2, image11.Height / 2, () => { return false; }, IntPtr.Zero);
Graphics g = Graphics.FromImage(validate_image);
g.Clear(Color.White);
g.DrawImage(image112, 0, 0);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
validate_image.Save(ms, ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/GIF";
Response.BinaryWrite(ms.ToArray());
g.Dispose();
validate_image.Dispose();
}
//翻转
imgPng.RotateFlip(RotateFlipType.Rotate180FlipX);
截取
Rectangle
rect = new
Rectangle(0, 0, imgPng.Width / 2, imgPng.Height);
Bitmap
clipPng = new
Bitmap(imgPng).Clone(rect, imgPng.PixelFormat);
摘自 Bychentufeiyang的专栏
补充:软件开发 , C# ,