从 Firefox 复制图像时出现黑色背景
图像从 Firefox 复制到剪贴板中。 我的程序从剪贴板获取它并保存为 JPEG 图像。 由于某种原因,图像以黑色背景保存。 如果我在 IE 中打开相同的 URL 并将图像复制到剪贴板中,则我的程序会正确保存图像。 我正在使用 Delphi 7。
我还尝试将图像从 Firefox 复制到 Microsoft Paint 中,并再次复制黑色背景。 有谁有如何处理此类问题的提示。
An image is copied from Firefox into the Clipboard. My program gets it from clipboard and saves as a JPEG image. For some reason the image is saved with a black background. If I open the same URL in IE and copy the image into the Clipboard, the image is saved correctly by my program. I am using Delphi 7.
I also tried to copy the image from Firefox into Microsoft Paint and again the black background. Does anyone has a tip in how to handle such problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设原始图像是透明的? 如果是这样,您应该知道 JPEG 无法处理透明度。 尝试切换输出图像类型,看看您的程序是否神奇地消失了。
I assume the original image is transparent? If so, you should be aware that JPEGs can't handle transparency. Try switching the output image type and seeing if you program magically goes away.
如果你的程序和 Paint 中得到相同的背景,那么这告诉我这与 Firefox 有关,因此这不一定是你要解决的问题。
由于您关心背景颜色,我猜您正在复制的图像具有透明元素。 那么请告诉我:应该是什么颜色? JPEG 图像不能有透明部分,因此每个像素都必须具有某种颜色。 Firefox 显然选择在那里放置黑色; 为什么这不是一个正确的选择,而 Internet Explorer 的却是正确的选择?
我想知道当您粘贴到比 Paint 更强大的图形程序(例如 Gimp 或 Photoshop)中时,您会得到什么颜色的背景。 我希望这些程序考虑多种剪贴板格式并选择最适当的格式,因此他们可能会选择一种在可用时支持透明度的格式。 另一方面,您的程序和 Paint 可能只使用 cf_Bitmap 格式,这种格式当然不能有透明像素,因此它们会获得复制程序选择用来填充空白的任何内容。
顺便说一句,Firefox 和 Internet Explorer 都允许您将图像直接从浏览器拖动到桌面或其他文件夹窗口以保存原始图像。 也许这会让你的程序变得不必要?
If you get the same background in your program and Paint, then that tells me this is something to do with Firefox, and thus it is not necessarily your problem to solve.
Since you're concerned about the background color, I guess the image you're copying has transparent elements to it. So tell me: What color should be there? A JPEG image can't have transparent parts, so every pixel must have some color. Firefox apparently chooses to put black there; how is that not a correct choice and Internet Explorer's is?
I wonder what color background you get when you paste into a more capable graphics program than Paint, such as Gimp or Photoshop. I would expect those programs to consider multiple clipboard formats and choose the most appropriate format, so they might choose a format that accommodates transparency when it's available. Your program and Paint, on the other hand, probably just use the
cf_Bitmap
format, which of course can't have transparent pixels, so they get whatever the copying program opted to use to fill in the blank space.By the way, both Firefox and Internet Explorer allow you to drag an image directly from the browser to the desktop or other folder window to save the original image. Maybe that makes your program unnecessary?
我知道这是一个有点老的问题,但我刚刚在 Firefox v9 中遇到了同样的问题。
使用以下解决方法:将有问题的图像保存到您的计算机,然后在资源管理器中复制文件并粘贴到您要使用的程序中(在我的例子中,我粘贴到word中)。
I know this is a slightly old question, but I've just come across the same issue in Firefox v9.
Use the following workaround: save the image in question to your computer, then copy the file in explorer and paste in the program you want to use (in my case I pasted into word).