转换BMP至PNG在内存中剪贴板净粘贴
这类似的问题的回答都要求要保存的文件。不过,我试图转换文件,然后将其复制到剪贴板。
This similar question's answers all require the file to be saved. However, I'm trying to convert the file and then copy it to the clipboard.
我怎么能转换成位图(或图片)为PNG,而不把它保存到文件系统?
How can I convert a Bitmap (or any image) to a PNG without saving it to the file system?
更新:
我试图将图像粘贴到一个应用程序(在此情况下的Evernote)。当你复制图像到剪贴板中(例如通过浏览器),它会记住它的图像格式,当您将其粘贴在,它会创建具有完全相同的格式的图像。例如,如果你复制一个PNG,将粘贴PNG。如果你复制一个JPG,它会贴一个JPG等。
Update:
I'm trying to paste the image into an application (in this case Evernote). When you copy an image into the clipboard (e.g. via the browser), it remembers its image format and when you paste it in, it will create an image with the same exact format. For example, if you copy a PNG, it will paste a PNG. If you copy a JPG, it will paste a JPG, etc.
我试图采取一切映像当前剪贴板中,它扩展到我想要的大小,然后保存在剪贴板为PNG,这样,当它被粘贴到Evernote的,它会创建一个PNG。
I am trying to take whatever image is currently in the clipboard, scale it to the size I want, and then keep it in the clipboard as a PNG, such that when it is pasted into Evernote, it will create a PNG.
当我复制一个PNG图像在我的浏览器,我看到下面的格式: HTML格式
, CF_BITMAP
, CF_DIB
, CF_DIBV5
。我不知道这些的Evernote使用粘贴。我下的是IM pression,这是 CF_BITMAP
,但看完下面的意见后,我想它使用的其他格式之一。
When I copy a PNG image in my browser, I see the following formats: HTML FORMAT
, CF_BITMAP
, CF_DIB
, CF_DIBV5
. I'm not sure which of these Evernote is using for pasting. I was under the impression that it was CF_BITMAP
, but after reading the comments below, I guess it's using one of the other formats.
我如何可以将图像中粘贴时,将被视为一个PNG剪贴板?
How can I place an image in the clipboard which will be treated as a PNG when pasted?
保存位图到一个MemoryStream
Save the Bitmap to a MemoryStream
byte[] result = null;
using (MemoryStream stream = new MemoryStream())
{
bitmap.Save(stream, ImageFormat.Png);
result = stream.ToArray();
}