• 批量生成不同尺寸的图片


    static void Main(string[] args)
    {
    var image = Image.FromFile("C:\picture\600.png");
    var pictureSize = new List<Picture>();
    pictureSize.Add(new Picture { Width = 256, Height = 256 });
    pictureSize.Add(new Picture { Width = 48, Height = 48 });
    pictureSize.Add(new Picture { Width = 24, Height = 24 });
    pictureSize.Add(new Picture { Width = 16, Height = 16 });
    //pictureSize.Add(new Picture { Width = 388, Height = 388 });
    foreach (var picture in pictureSize)
    {
    Bitmap map = new Bitmap(picture.Width, picture.Height);
    Graphics graphics = Graphics.FromImage(map);
    graphics.CompositingQuality = CompositingQuality.HighQuality;
    graphics.SmoothingMode = SmoothingMode.HighQuality;
    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
    var imageRectangle = new Rectangle(0, 0, picture.Width, picture.Height);
    graphics.DrawImage(image, imageRectangle);
    map.Save("C:\picture\result\"+picture.Width + "x" + picture.Height+".png", ImageFormat.Png);
    graphics.Dispose();
    map.Dispose();
    }
    image.Dispose();
    }

    public class Picture
    {
    public int Height { get; set; }
    public int Width { get; set; }
    }

  • 相关阅读:
    javaScript设计模式:装饰模式
    搭建自动签到服务
    Gmail邮箱注册
    springcloud3(六) 服务降级限流熔断组件Resilience4j
    PCB
    行业_激光
    Git设置Http代理,克隆github上的代码
    工控机与运动控制卡
    锂电池生产工艺
    PCB涂胶工艺
  • 原文地址:https://www.cnblogs.com/wuwei928/p/5892078.html
Copyright © 2020-2023  润新知