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

  • 相关阅读:
    Android相对布局中控件的常用属性【转】
    Android:仿微信设置菜单
    Android:scrollview与listview共存
    感想12.26
    (C#)GDI+绘制垂直文字
    10.14 近期小结
    学习C++的忠告
    C# TCP学习笔记
    C#读书笔记(4)—重学数组
    近期学习计划 12.23
  • 原文地址:https://www.cnblogs.com/wuwei928/p/5892078.html
Copyright © 2011-2022 走看看