一键生成Android/Android-HD/IOS 多尺寸ICON
发表于2017-11-18
ICON一般都会有很多个尺寸,如果一个个尺寸去弄会很浪费时间,所以就写了个小工具,一键生成Android/Android-HD/IOS 多尺寸ICON,下面就将方法分享给大家。
工具下载地址:http://download.csdn.net/detail/cp790621656/9873029
源码地址:https://github.com/ThisisGame/MultiSizeIcon
主要代码如下:
private void button1_Click(object sender, EventArgs e)
{
FileStream stream = File.OpenRead("./app_icon.png");
int fileLength = 0;
fileLength = (int)stream.Length;
Byte[] image = new Byte[fileLength];
stream.Read(image, 0, fileLength);
System.Drawing.Image result = System.Drawing.Image.FromStream(stream);
stream.Close();
string[] tmpAndroidIconFolder = { "drawable", "drawable-hdpi", "drawable-ldpi", "drawable-mdpi", "drawable-xhdpi", "drawable-xxhdpi", "drawable-xxxhdpi" };
int[] tmpAndroidIconSize = { 48, 72, 36, 36, 96, 144, 192 };
for (int i = 0; i < tmpAndroidIconFolder.Length; i++)
{
Size s = new Size(tmpAndroidIconSize[i], tmpAndroidIconSize[i]);
Bitmap newBit = new Bitmap(result, s);
string tmpIconPath = "./Android/" + tmpAndroidIconFolder[i] ;
if(Directory.Exists(tmpIconPath)==false)
{
Directory.CreateDirectory(tmpIconPath);
}
newBit.Save(tmpIconPath + "/app_icon.png");
newBit.Dispose();
}
MessageBox.Show("Finish");
}
这样大家就可以获得自己想要的ICON的规格了。
