Esempio n. 1
0
        private void GetBitmap()
        {
            Bitmap bm = _host.ExportToBitmap(PixelFormat.Format24bppRgb);

            _bmps.Add(bm);
            _index++;
        }
Esempio n. 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.Filter = "所有图像(*.bmp,*.jpg,*.jpeg,*.png,*.tiff,*.tif)|*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.png";
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ImageFormat imgFormat = ImageFormat.Bmp;
                    string      extName   = Path.GetExtension(dlg.FileName.ToUpper());
                    switch (extName)
                    {
                    case ".BMP":
                        imgFormat = ImageFormat.Bmp;
                        break;

                    case ".JPEG":
                    case ".JPG":
                        imgFormat = ImageFormat.Jpeg;
                        break;

                    case ".TIF":
                    case ".TIFF":
                        imgFormat = ImageFormat.Tiff;
                        break;

                    case ".PNG":
                        imgFormat = ImageFormat.Png;
                        break;
                    }
                    using (Bitmap bmp = _host.ExportToBitmap(PixelFormat.Format32bppArgb))
                    {
                        bmp.Save(dlg.FileName, imgFormat);
                    }
                }
            }
        }