• App图标生成器的实现,附源码


    背景

    网上各种生成app图标的网站和工具,感觉还是用自己写的心里畅快点,所以花了1个小时自己写了个。按照网上给的图标尺寸规范把所有尺寸的都生成了。

    建了一个讨论群,533838427。很明显是针对独立开发的兄弟的,这小程序也看出来了,android、ios一把抓,希望也在趟这苦海的朋友一起交流。

    源码下载地址:

    链接: http://pan.baidu.com/s/1qXuZgXu 密码: ihfp

    说明

    c#写的,生成Andorid和Ios的所有图标尺寸。要是觉得尺寸不对或者命名规则不合适自己可以代码里立刻修改。代码里面备注还是很详细的。

    1.修改尺寸

    在Model里,把Android和Ios的尺寸分开保存在数组里面,可以根据需要调整。

     public class AndroidSizes
        {
            public static int[] mdpiSizes = { 48, 32, 16, 24 };
            public static int[] hdpiSizes = { 72,48,24,36 };
            public static int[] xhdpiSizes = { 48, 32, 16, 24 };
            public static int[] xxhdpiSizes = { 144, 96, 48, 72 };
        }
    
        public class IosSizes
        {
            public static int[] icon3Sizes = { 1024, 512, 180, 114, 87, 75, 66 };
            public static int[] icon2Sizes = { 1024, 512, 120, 114, 58, 75, 44 };
            public static int[] icon1Sizes = { 1024, 512, 120, 57, 29, 38, 30 };
        }

    2.修改保存文件夹和命名规范

    现在的文件夹命名规范是ios按1X、2X、3X直接保存在一个文件夹里面,按类型命名

    android是按照xhdpi、hdpi、xxhdpi分别保存的,按尺寸命名

    如果要修改命名可以在form的backgroundworker里面找到,这里图省事就直接逻辑写进去了。

       private string CreateFolder(string file)
            {
                string filePath = Path.GetDirectoryName(file);
                string fileName = Path.GetFileNameWithoutExtension(file);
                string root = filePath + "\" + fileName;
                //根目录
                if (!Directory.Exists(root))
                {
                    Directory.CreateDirectory(root);
                }
                //子目录
                foreach (string child in childFolders)
                {
                    if (!Directory.Exists(root + "\" + child))
                    {
                        Directory.CreateDirectory(root + "\" + child);
                    }
                }
                return root;
            }
    
            private void CreateIOSThumbs(string folder, string file)
            {
                //@1x
                foreach (int size in Model.IosSizes.icon1Sizes)
                {
                    string thumb = folder + "\ios\@1x" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
    
                //@2x
                foreach (int size in Model.IosSizes.icon2Sizes)
                {
                    string thumb = folder + "\ios\@2x" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
    
                //@3x
                foreach (int size in Model.IosSizes.icon3Sizes)
                {
                    string thumb = folder + "\ios\@3x" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
            }
    
            private void CreateANDROIDThumbs(string folder, string file)
            {
                // "android", "android\hdpi", "android\mdpi", "android\xhdpi", "android\xxhdpi"
                //hdpi
                foreach (int size in Model.AndroidSizes.hdpiSizes)
                {
                    string thumb = folder + "\android\hdpi\" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
                //mdpi
                foreach (int size in Model.AndroidSizes.mdpiSizes)
                {
                    string thumb = folder + "\android\mdpi\" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
    
                //xhdpi
                foreach (int size in Model.AndroidSizes.xhdpiSizes)
                {
                    string thumb = folder + "\android\xhdpi\" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
    
                //xxhdpi
                foreach (int size in Model.AndroidSizes.xxhdpiSizes)
                {
                    string thumb = folder + "\android\xxhdpi\" + size + ".png";
                    DAL.ImageConvert.MakeThumbnail(file, thumb, size, size, "HW");
                }
            }

    参考

    http://www.uigreat.com/guifan/  尺寸规范

    http://www.cnblogs.com/zzy2740/archive/2012/02/29/2374648.html  缩略图生成

    自己在做独立开发,希望广结英豪,尤其是像我一样脑子短路不用react硬拼anroid、ios原生想干点什么的朋友。

    App独立开发群533838427

    微信公众号『懒文』-->lanwenapp<--

  • 相关阅读:
    家庭网关
    linux -jdk 安装
    linux 常见命令--系统信息部分
    pyglet--EventLoop对象(主事件循环,用于从系统消息队列中取出消息,并派发给各个窗口)
    ATL com的dll文件与tlb文件
    MFC实现COM组件
    如何定义一个接口(接口Interface只在COM组件中定义了,MFC和C++都没有接口的概念)
    关于DLL调试的两个工具(dependency walker和dumpbin.exe)
    MFC工程名称与所包含文件名称的关系(工程名可以更改,输出的.dll.exe.lib都以最后工程名命名为准)
    关于c++中命名空间namespace
  • 原文地址:https://www.cnblogs.com/matoo/p/5147032.html
Copyright © 2020-2023  润新知