从Firefox复制图像时的黑色背景

时间:2023-01-30 09:43:21

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.

将图像从Firefox复制到剪贴板中。我的程序从剪贴板获取它并保存为JPEG图像。由于某种原因,图像以黑色背景保存。如果我在IE中打开相同的URL并将图像复制到剪贴板中,我的程序将正确保存图像。我正在使用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.

我还尝试将图像从Firefox复制到Microsoft Paint,再次尝试将黑色背景复制到。有没有人知道如何处理这样的问题。

3 个解决方案

#1


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.

我假设原始图像是透明的?如果是这样,您应该知道JPEG无法处理透明度。尝试切换输出图像类型,看看你是否神奇地编程消失了。

#2


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.

如果你在程序和Paint中获得相同的背景,那么这告诉我这与Firefox有关,因此它不一定是你需要解决的问题。

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?

由于你担心背景颜色,我猜你正在复制的图像具有透明元素。那么告诉我:应该有什么颜色? JPEG图像不能具有透明部分,因此每个像素必须具有一些颜色。 Firefox显然选择在那里放黑色;怎么这不是一个正确的选择和Internet Explorer的?

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.

我想知道当你粘贴到一个比Paint更强大的图形程序时你得到的颜色背景,比如Gimp或Photoshop。我希望这些程序能够考虑多种剪贴板格式并选择最合适的格式,这样他们就可以选择一种在可用时适应透明度的格式。另一方面,你的程序和Paint可能只使用cf_Bitmap格式,当然它不能有透明像素,因此它们可以获得复制程序选择用于填充空白区域的任何内容。

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和Internet Explorer都允许您将图像直接从浏览器拖动到桌面或其他文件夹窗口以保存原始图像。也许这会使你的程序变得不必要

#3


I know this is a slightly old question, but I've just come across the same issue in Firefox v9.

我知道这是一个稍微陈旧的问题,但我在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).

使用以下解决方法:将有问题的图像保存到您的计算机,然后在资源管理器中复制该文件并粘贴您要使用的程序(在我的情况下,我粘贴到word中)。

#1


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.

我假设原始图像是透明的?如果是这样,您应该知道JPEG无法处理透明度。尝试切换输出图像类型,看看你是否神奇地编程消失了。

#2


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.

如果你在程序和Paint中获得相同的背景,那么这告诉我这与Firefox有关,因此它不一定是你需要解决的问题。

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?

由于你担心背景颜色,我猜你正在复制的图像具有透明元素。那么告诉我:应该有什么颜色? JPEG图像不能具有透明部分,因此每个像素必须具有一些颜色。 Firefox显然选择在那里放黑色;怎么这不是一个正确的选择和Internet Explorer的?

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.

我想知道当你粘贴到一个比Paint更强大的图形程序时你得到的颜色背景,比如Gimp或Photoshop。我希望这些程序能够考虑多种剪贴板格式并选择最合适的格式,这样他们就可以选择一种在可用时适应透明度的格式。另一方面,你的程序和Paint可能只使用cf_Bitmap格式,当然它不能有透明像素,因此它们可以获得复制程序选择用于填充空白区域的任何内容。

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和Internet Explorer都允许您将图像直接从浏览器拖动到桌面或其他文件夹窗口以保存原始图像。也许这会使你的程序变得不必要

#3


I know this is a slightly old question, but I've just come across the same issue in Firefox v9.

我知道这是一个稍微陈旧的问题,但我在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).

使用以下解决方法:将有问题的图像保存到您的计算机,然后在资源管理器中复制该文件并粘贴您要使用的程序(在我的情况下,我粘贴到word中)。