Esempio n. 1
0
        void Save_FileBarcode()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter       = "BMP (*.bmp)|*.bmp|GIF (*.gif)|*.gif|JPG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif";
            sfd.FilterIndex  = 2;
            sfd.AddExtension = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                BarcodeLib.SaveTypes savetype = BarcodeLib.SaveTypes.UNSPECIFIED;
                switch (sfd.FilterIndex)
                {
                case 1: /* BMP */ savetype = BarcodeLib.SaveTypes.BMP; break;

                case 2: /* GIF */ savetype = BarcodeLib.SaveTypes.GIF; break;

                case 3: /* JPG */ savetype = BarcodeLib.SaveTypes.JPG; break;

                case 4: /* PNG */ savetype = BarcodeLib.SaveTypes.PNG; break;

                case 5: /* TIFF */ savetype = BarcodeLib.SaveTypes.TIFF; break;

                default: break;
                }//switch
                barcodeLib.SaveImage(sfd.FileName, savetype);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter       = "BMP (*.bmp)|*.bmp|GIF (*.gif)|*.gif|JPG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif";
            sfd.FilterIndex  = 3;
            sfd.AddExtension = true;
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                BarcodeLib.SaveTypes savetype = BarcodeLib.SaveTypes.UNSPECIFIED;
                switch (sfd.FilterIndex)
                {
                case 1: /* BMP */ savetype = BarcodeLib.SaveTypes.BMP; break;

                case 2: /* GIF */ savetype = BarcodeLib.SaveTypes.GIF; break;

                case 3: /* JPG */ savetype = BarcodeLib.SaveTypes.JPG; break;

                case 4: /* PNG */ savetype = BarcodeLib.SaveTypes.PNG; break;

                case 5: /* TIFF */ savetype = BarcodeLib.SaveTypes.TIFF; break;

                default: break;
                }

                //Bitmap bitmap = new Bitmap(b.EncodedImage);
                //var fff = 140;//(float)Convert.ToDouble(dpiBox.Text);
                //设置其生成图片的dpi
                //bitmap.SetResolution(fff, fff);
                //bitmap.Save(sfd.FileName);
                bar.SaveImage(sfd.FileName, savetype);
            }
        }