Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1.  
  2. // Изменение размера изображения
  3. public Image ResizeImg(Image b, int nWidth, int nHeight)
  4. {
  5. Image result = new Bitmap(nWidth, nHeight);
  6. using (Graphics g = Graphics.FromImage((Image)result))
  7. {
  8. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  9. g.DrawImage(b, 0, 0, nWidth, nHeight);
  10. g.Dispose();
  11. }
  12. return result;
  13. }
  14. // Поворот на угол , вводишь, допустим Bitmap temp = new Bitmap(pictureBox1.Image); pictureBox1.Image= rotateImage(temp, 25);
  15. // это поворот на 25 градусов
  16. private Bitmap rotateImage(Bitmap input, float angle)
  17. {
  18. Bitmap result = new Bitmap(input.Width, input.Height);
  19. Graphics g = Graphics.FromImage(result);
  20. g.TranslateTransform((float)input.Width / 2, (float)input.Height / 2);
  21. g.RotateTransform(angle);
  22. g.TranslateTransform(-(float)input.Width / 2, -(float)input.Height / 2);
  23. g.DrawImage(input, new Point(0, 0));
  24. return result;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement