Koyomi www.sebastiengilles.com | Voila, a toi d'adapter Code :
- private static Image ScaleByPercent(Image imgPhoto, int Percent)
- {
- float nPercent = ((float)Percent / 100);
- int sourceWidth = imgPhoto.Width;
- int sourceHeight = imgPhoto.Height;
- int sourceX = 0;
- int sourceY = 0;
- int destX = 0;
- int destY = 0;
- int destWidth = (int)(sourceWidth * nPercent);
- int destHeight = (int)(sourceHeight * nPercent);
- Bitmap bmPhoto = new Bitmap(destWidth, destHeight,
- PixelFormat.Format24bppRgb);
- bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
- imgPhoto.VerticalResolution);
- Graphics grPhoto = Graphics.FromImage(bmPhoto);
- grPhoto.InterpolationMode = InterpolationMode.HighQualityBilinear;
- grPhoto.DrawImage(imgPhoto,
- new Rectangle(destX, destY, destWidth, destHeight),
- new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
- GraphicsUnit.Pixel);
- grPhoto.Dispose();
- return bmPhoto;
- }
| |