Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ublic static Bitmap ChangeSize(this Bitmap bitmap, int height, double proportion)
- {
- if (Math.Abs(1-proportion)<double.Epsilon)
- {
- var newWidth = bitmap.Height / height * bitmap.Height;
- return bitmap.ChangeSize(newWidth,height);
- }
- var width = (int)(bitmap.Height * proportion);
- var middle = bitmap.Width / 2;
- var margin = (middle - (width /2));
- return bitmap.Clone(
- new System.Drawing.Rectangle(margin, 0, width, bitmap.Height),
- bitmap.PixelFormat);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement