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.
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.
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?
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).
Related
I edited a simple png image with gimp, but it made transparent background black. So I tried undo'ing it, but nothing changed. Then I completely deleted all pixels (ctrl+A and delete) - this made image completely blank (white). But then I read it with OpenCV (python, ubuntu 16.04) and I still could see that old picture!
This is simple code I used to read image. As you can see it is completely blank (white).
But then I run the code and I can still see the old picture!
Here you can see - it is completely empty. I opened it with Firefox, Gimp, default ubuntu image viewer, windows photo viewer - same blank image.
So I decided to try something and I drawed with Gimp on that picture:
And I ran same code again:
After undo'ing question mark image returned to same. I figured - it could be some software error - I rebooted - same. Then I copied 'nothing.png' to Win10. Same code - same result. Image is about 449kB size. Here it is:
What the hell is going on here?
GIMP didn't erase the RGB data, it just sets the alpha channel to 0.
That's enough... unless you ignore the alpha channel.
OpenCV ignores the alpha channel... it's just another channel, not special at all. OpenCV can read and write RGBA data, and you can use the alpha channel like any other channel. It's just that display with imshow ignores the alpha channel and shows you the RGB data.
Icons Are Pretty Right?
I'm working on an UI update in an iOS app, and trying to make things look a bit better with some new icons- but I seem to be incapable of determining how to save an image correctly so that it looks good in the interface!
As you can see from this image, if I include a white background with the image it looks great. If I take those same images and use an alpha background they look terrible! It appears that either the images aren't using the #2x correctly, or something else is going horribly wrong.
These images are either saved with GIMP as a png with alpha, or exported from inkscape, the originals are vector graphics. We get the same results from both avenues. I am using both a base imageName.png and imageName#2x.png for scaling.
Somehow, magically, I changed the a single image to greyscale in gimp, and changed the base size to 25px and it showed up with alpha correctly blended. Stock images from apple are also functioning correctly, so it absolutely seems to be something that I'm doing incorrectly when I'm saving the images.
The Setup in XCode
Basic Questions
Is there a certain bit depth, argb vs rgba format, or some other quirk that I need to know to get these images to show up correctly? Is there any way to verify that the program is loading the correct imageName#2x vs imageName? Is there some document that talks about integrated graphics (the iconography documentation isn't very helpful on technical details)
Actual Images
With Background:
Without Background:
I think you will find success if you just save the image at 4x the size you actually want and specify the size manually.
I am having my app icon be displayed as a black square instead of the intended image.
I have placed all of my AppIcons into the folder, Im wondering what could be causing this.
Your image needs to be an opaque PNG. No transparency or anything, as well as being the correct size.
If it already is that, try opening it in Preview and re-saving it as a PNG. That way OS X 'generated' it and it should be compatible. If that helps fix the issue, then your image editing program is saving in the wrong format...see info below.
Apple has this to say on generating PNGs:
For all images and icons, the PNG format is recommended. You should avoid using interlaced PNGs.
The standard bit depth for icons and images is 24 bits—that is, 8 bits each for red, green, and blue—plus an 8-bit alpha channel.
I have had this happen when the app is listed as a .png file, but the system is recognizing it as a .jpg or some other type ... find your icon in "finder" and open it with preview, go to the file menu select "export as" and make sure you choose PNG as the save format. Delete the old version in the application, delete the derived data, clean your project, and rebuild the application.
Delphi 2010's TSpeedButtons did not seem to really support PNG transparency properly, because the Glyph property uses a TBitmap internally, and TBitmap is for bitmaps, and doesn't support PNG transparency properly, and TSpeedButton.Glyph can't support transparency then.. update: But the actual problem was that I had some external stuff (Developer Express components) that was rendering delphi's PNG support non-functional, TImage on the other hand, while it still TPicture, and can support PNG, was also affected by this Developer express bug.
A question was already asked about here, and the answer shows how to use pre-blending so that transparency won't turn into black pixels. I want to know if there is another button control that will use alpha-blended PNGs loaded at designtime, and which does not convert the PNG resources into BMP format discarding the alpha channel and, causing the black border shown here.
In short, this control would not use TBitmap, and would not use the color key transparency feature that is all TBitmap has.
To repeat, I am not asking how to solve the black-around-the-outside issue while still using the out-of-date TBitmap/TSpeedButton based VCL functionality, because it lacks modern PNG transparency functionality, I am asking about replacing it with something else that "just works".
As a secondary drawback, converting a small .png file into a .DFM bitmap resource is essentially wasting space and making my form .DFM content too large. Native .png file format storage within the .dfm should make the resulting forms smaller.
Update: PngComponents look like they should work, but I got an Invalid Graphic format error when I try to load a png into the Png speedbutton. Note that the Png image list component has no such problems. It seems that cxLibrary (a developer express package) is breaking things. Once I removed all developer express stuff, this problem goes away. So although I have selected Pngcomponents as the answer, if you have devex stuff installed, use their buttons instead, and not pngcomponents.
You may have a look at PngComponents. It has a TPngSpeedbutton and some other controls working directly with PngImages.
You could also look into the TMS Software Component called TAdvGlowButton as this supports PNG images with alpha transparency.
Link to site...
It turns out that cxButton that comes in the Developer Express VCL component pack also supports PNG buttons.
I have a filmstrip of images in png format like this:
I'd like to know how to clip each of the images and put these images in a TImageList control, always preserving the transparency.
[EDIT]
Yes, at designtime the trick mentioned by RRUZ works fine, but I wanted to clip the images at runtime, i.e. by loading the filmstrip from resource or file
You must follow these steps:
set ColorDepth property to cd32Bit,
DrawingStyle to dsTransparent,
Height= 48,
Width=48,
then load the image and the result will be
Just import into the imagelist. It'll complain that it's too big and offer to break it into pieces for you. Works fine for me on D2005.
Another cool tip: I use AWIcons Pro http://www.awicons.com/icon-editor/ to edit icons (nice editor!). It has a feature that can export an icon as an imagelist (.bmp or .png format), thus making the filmstrip out of an icon. This makes it really handy to edit these things in .ico format, with a series of cells all the same size and depth, with each cell varying slightly. Then you export as an imagelist (I use .png) and then Delphi can break them back out into individual cells. Very slick. AWIcons isn't free, but features like this really make it productive.
At runtime, you would have to call TImageList.FileLoad. Except it won't work.
This in turn calls ImageList_LoadImage, with uFlags parameter value including the bit LR_LOADFROMFILE, which causes Windows to load from a file on disk. This underlying functionality only supports TBitmap (BMP) format.
See the nearly-duplicate question. PNG support is a designtime feature that is converting the PNG data into an internal non-PNG and not-exactly-a-BMP-either format, used internally by MS Common Controls library. View your DFM as text, and you will see what your PNG inputs have been turned into. The other answers show you that transparency is preserved, using bitmap-color based transparency.
If you want to keep your data in PNG format, you shouldn't be using a VCL TImageList to store it, because you're going to have to do a conversion from PNG to TBitmap to actually use TImageList.