Exemple #1
0
        //将文件转换为bmp 256色
        void convertBitmap(String fileName, String outFile)
        {
            Bitmap bitmap       = new Bitmap(fileName);
            String outName      = Path.GetFileNameWithoutExtension(fileName);
            Bitmap bitmapResult = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format8bppIndexed);
            String outFileName  = Path.Combine(SVProData.IconPath, outFile);

            ///如果已经存在,不执行该文件的导入
            if (_pixmapManage.isItemExist(outName))
            {
                SVLog.WinLog.Warning(String.Format("图元名称{0} 已经存在, 导入失败!", outName));
                return;
            }

            MemoryStream outStream = new MemoryStream();

            bitmapResult.Save(outStream, ImageFormat.Bmp);

            //保存文件
            SVPixmapFile pixFile = new SVPixmapFile();

            pixFile.ShowName = outName;
            pixFile.Pixmap   = outStream;

            imageList.Images.Add(outName, pixFile.getBitmapFromData());
            imageList1.Images.Add(outName, pixFile.getBitmapFromData());

            pixFile.writePixmapFile(outFileName);

            if (this.listRadio.Checked)
            {
                listView.View           = View.Details;
                listView.SmallImageList = imageList;
                listView.LargeImageList = imageList1;
            }
            else
            {
                listView.View           = View.LargeIcon;
                listView.SmallImageList = imageList1;
                listView.LargeImageList = imageList1;
            }

            ListViewItem viewItem = listView.Items.Add(outName);

            viewItem.ImageKey = outName;

            _pixmapManage.insertItemByClass(treeView.SelectedNode.Text, outName, outFile);
            saveIconInfo();
        }
Exemple #2
0
        //将文件转换为bmp 256色
        void convertBitmap(String fileName, String outFile)
        {
            Bitmap bitmap       = new Bitmap(fileName);
            Bitmap bitmapResult = bitmap;
            //Bitmap bitmapResult = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format8bppIndexed);

            String outName     = Path.GetFileNameWithoutExtension(fileName);
            String outFileName = Path.Combine(SVProData.IconPath, outFile);

            MemoryStream outStream = new MemoryStream();

            bitmapResult.Save(outStream, ImageFormat.Bmp);

            //保存文件
            SVPixmapFile pixFile = new SVPixmapFile();

            pixFile.ShowName = outName;
            pixFile.Pixmap   = outStream;
            ///执行写文件过程
            pixFile.writePixmapFile(outFileName);
            _picManager.insertItemByClass(this.classlistView.SelectedValue as String, outName, outFile);
        }