1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle Rect_fond = new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight);
// grPhoto.FillRectangle(new SolidBrush(Color.White), Rect_fond);
grPhoto.DrawImage(imgPhoto,
new Rectangle(destX, destY, destWidth, destHeight),
Rect_fond,
GraphicsUnit.Pixel);
// this.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
// this.BackColor = Color.FromArgb(0, 128, 128, 128);
bmPhoto.Save(destImag, System.Drawing.Imaging.ImageFormat.Png);
grPhoto.Dispose(); |
Partager