Esempio n. 1
0
        private void picSrc_DragDrop(Object sender, DragEventArgs e)
        {
            var fs = (String[])e.Data.GetData(DataFormats.FileDrop);

            if (fs != null && fs.Length > 0)
            {
                var fi = fs[0];
                sfd.FileName = fi;

                // 如果是图标,读取信息
                if (fi.EndsWithIgnoreCase(".ico"))
                {
                    var ico = new IconFile(fi);
                    //ico.Sort();
                    var sb = new StringBuilder();
                    foreach (var item in ico.Items)
                    {
                        if (sb.Length > 0)
                        {
                            sb.AppendLine();
                        }
                        sb.AppendFormat("{0}*{1}*{2}", item.Width, item.Height, item.BitCount);
                    }
                    MessageBox.Show(sb.ToString());
                }
                picSrc.Load(fi);
            }
        }
Esempio n. 2
0
        private void btnMakeICO_Click(Object sender, EventArgs e)
        {
            var list = new List <Int32>();

            foreach (var item in groupBox2.Controls)
            {
                var chk = item as CheckBox;
                if (chk != null && chk.Checked)
                {
                    list.Add(chk.Name.Substring(3).ToInt());
                }
            }
            list.Sort();

            if (list.Count < 1)
            {
                MessageBox.Show("请选择大小!");
                return;
            }

            var bmp = MakeWater(true);

            var ms = new MemoryStream();

            //IconFile.Convert(bmp, ms, list.ToArray(), new Int32[] { 8, 32 });
            IconFile.Convert(bmp, ms, list.ToArray(), new Int32[] { 32 });

            //sfd.DefaultExt = "ico";
            sfd.Filter = "ICO图标(*.ico)|*.ico";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                File.WriteAllBytes(sfd.FileName, ms.ToArray());
            }
        }
Esempio n. 3
0
        public static void Convert(Image bmp, Stream des, Int32[] sizes, Int32[] bits)
        {
            var ico = new IconFile();

            foreach (var bit in bits)
            {
                foreach (var item in sizes)
                {
                    if (bit == 8)
                    {
                        ico.AddBmp(bmp, item, bit);
                    }
                    else
                    {
                        ico.AddPng(bmp, item, bit);
                    }
                }
            }
            ico.Sort();

            ico.Save(des);
        }
Esempio n. 4
0
        public static void Convert(String srcfile, String desfile, Int32[] sizes, Int32[] bits)
        {
            using (var bmp = new Bitmap(srcfile))
            {
                var ico = new IconFile();
                foreach (var bit in bits)
                {
                    foreach (var item in sizes)
                    {
                        if (bit == 8)
                        {
                            ico.AddBmp(bmp, item, bit);
                        }
                        else
                        {
                            ico.AddPng(bmp, item, bit);
                        }
                    }
                }

                ico.Save(desfile);
            }
        }