Ejemplo 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)
            {
                try
                {
                    var fi = fs[0];
                    sfd.FileName = fi;
                    picSrc.Load(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.Append(",");
                            }
                            sb.AppendFormat("{0}*{1}", item.Width, item.BitCount);
                        }
                        MessageBox.Show(sb.ToString());
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 2
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);
        }