zoukankan      html  css  js  c++  java
  • 批量生成不同尺寸的图片

    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; }
    }

  • 相关阅读:
    P1439 【模板】最长公共子序列
    DP,入门???
    关于Eclipse在servlet中连接数据库时出现驱动加载失败的解决
    JSP学习(JavaBean)
    HTML随笔3
    CSS随笔3
    计算机网络随笔
    基本命令行操作1(java编译)
    Javascript随笔2(JQuery)
    Javascrip随笔1
  • 原文地址:https://www.cnblogs.com/wuwei928/p/5892078.html
Copyright © 2011-2022 走看看