1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| private void Rot(RotateFlipType rotateFlipType)
{
int oWidth = img.Width;
int oHeight = img.Height;
Bitmap tmp = new Bitmap(oWidth, oHeight);
float m = oWidth - ((float)oHeight / 1.333333f);
int marge = (int)m / 2;
img.RotateFlip(rotateFlipType);
Rectangle srcRect = new Rectangle(0, 0, img.Width, img.Height);
Rectangle dstRect = new Rectangle(marge, 0, oWidth - (int)m, oHeight);
Graphics gr = Graphics.FromImage(tmp);
GraphicsUnit units = GraphicsUnit.Pixel;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.Clear(Color.WhiteSmoke);
gr.DrawImage(img, dstRect, srcRect, units);
img = tmp;
putImage();
} |
Partager