public static Image Zoom(Image source, int width, int height, bool isDeformation) { Image result; if (isDeformation) { result = ImageTo.Zoom(source, width, height); } else { double num = (double)width / (double)source.Width; double num2 = (double)height / (double)source.Height; double num3 = (num > num2) ? num : num2; int num4 = Convert.ToInt32((double)source.Width * num3); int num5 = Convert.ToInt32((double)source.Height * num3); num4 = ((num4 >= source.Width) ? source.Width : num4); num5 = ((num5 >= source.Height) ? source.Height : num5); Bitmap bitmap = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(bitmap); graphics.Clear(Color.White); graphics.DrawImage(source, (width - num4) / 2, (height - num5) / 2, num4, num5); graphics.Dispose(); result = bitmap; } return(result); }
public static Image Thumbnail(Image source, int percent) { int width = source.Width * percent / 100; int height = source.Height * percent / 100; return(ImageTo.Thumbnail(source, width, height)); }
public static Image Overlay(Image source, Image img, string overType, int opacity) { string text = overType.ToLower(); int x; int y; switch (text) { case "left": x = 0; y = (source.Height - img.Height) / 2; goto IL_1B6; case "right": x = source.Width - img.Width; y = (source.Height - img.Height) / 2; goto IL_1B6; case "top": x = (source.Width - img.Width) / 2; y = 0; goto IL_1B6; case "down": x = (source.Width - img.Width) / 2; y = source.Height - img.Height; goto IL_1B6; case "lefttop": x = 0; y = 0; goto IL_1B6; case "leftdown": x = 0; y = source.Height - img.Height; goto IL_1B6; case "righttop": x = source.Width - img.Width; y = 0; goto IL_1B6; case "rightdown": x = source.Width - img.Width; y = source.Height - img.Height; goto IL_1B6; } x = (source.Width - img.Width) / 2; y = (source.Height - img.Height) / 2; IL_1B6: return(ImageTo.Overlay(source, img, x, y, opacity)); }
public static Image Thumbnail(Image source, int width, int height) { int num = source.Width; int num2 = source.Height; double num3 = (double)width / (double)source.Width; double num4 = (double)height / (double)source.Height; double num5 = (num3 > num4) ? num3 : num4; num = Convert.ToInt32((double)source.Width * num5); num2 = Convert.ToInt32((double)source.Height * num5); num = ((num >= source.Width) ? source.Width : num); num2 = ((num2 >= source.Height) ? source.Height : num2); Bitmap bitmap = new Bitmap(num, num2); Graphics graphics = Graphics.FromImage(bitmap); graphics.InterpolationMode = InterpolationMode.High; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.DrawImage(source, 0, 0, num, num2); graphics.Dispose(); return(ImageTo.Cute(bitmap, (bitmap.Width - width) / 2, (bitmap.Height - height) / 2, width, height)); }
public static Image Overlay(Image source, string text, string overType, int opacity, int size, string font, string color) { Image img = ImageTo.FromString(text, size, font, color); return(ImageTo.Overlay(source, img, overType, opacity)); }
public static Image Overlay(Image source, string text, string overType, int opacity) { Image img = ImageTo.FromString(text, 12, "宋体", "#ff0000"); return(ImageTo.Overlay(source, img, overType, opacity)); }
public static Image Overlay(Image source, Image img, int x, int y, int opacity) { img = ImageTo.Transparent(img, opacity); return(ImageTo.Overlay(source, img, x, y)); }