从clipBoard c#保存图片

时间:2014-03-27 13:27:12

标签: c# visual-studio-2012

所以我一直在搞乱prtscn后从剪贴板保存图像。现在我遇到的问题是下面的代码很慢。我试图保存一个图像,当我这样做时它会快一点。但是当它保存图片时,它们仍然是一个明显的滞后..

 if (Clipboard.GetDataObject() != null)
        {
            IDataObject data = Clipboard.GetDataObject();

            if (data.GetDataPresent(DataFormats.Bitmap))
            {
                Image image = (Image)data.GetData(DataFormats.Bitmap, true);

                image.Save("image.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                image.Save("image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                image.Save("image.gif", System.Drawing.Imaging.ImageFormat.Gif);
            }
            else
            {
                MessageBox.Show("The Data In Clipboard is not as image format");
            }
        }
        else
        {
            MessageBox.Show("The Clipboard was empty");
        }

0 个答案:

没有答案