I thought I'd share this neat little bug with everyone here. When r2 was released, I started seeing reports about people's images on Windows starting to have blue in them instead of the transparency. What was even more odd was that I couldn't reproduce the issue on Vista, but others could. I could reproduce on XP (but some others couldn't). What the heck, right? The problem was specific to pictures which had alpha channels in them and were dragged into the project.
Well, you see... the problem was that when you drag a picture with an alpha channel into the IDE on Windows, we convert the alpha channel to a mask picture for you under the hood. This mask picture isn't exposed to you in any way (since it doesn't need to be), and you can override it however you'd like. However, when you go to compile your project out, we would only embed one file. But that file is a BMP file (for system compatibility reasons), and those don't have an alpha channel to them. So the alpha would be undefined (which is expected when using SaveAsPicture), and when your application would try to display that picture, it would get the BMP with no alpha information in it.
It just so happened that for r1, "undefined" meant white for most people. So if you had set Transparent = white on the picture, then everything just magically worked! However, "undefined" shifted over to blue for whatever reason in r2 for some people, so the magic suddenly didn't work.
The solution is to embed the special mask into your built executable as well, so we can get the complete picture object back from the executable. Note that this makes your executable larger since we need to embed two pictures instead of one.
So, fascinatingly enough, your application worked entirely by chance in r1 (and for me in r2 when on Vista, but not while on XP). Thankfully, in a future release (since we don't talk about this in public, I won't promise you which one), it'll work by design instead.
This was quite a head-scratcher for me, but once I realized the underlying issue, it suddenly made a lot of sense.
Can you think of a way of faking this in r2?
Sure -- don't drag pictures with alpha masks into your project. The best thing you can do is drag in a BMP file (since then we don't have to convert it, so you can be assured your data isn't monkeyed with at all), and then either set the Transparent flag on the picture, or drag in and hook up a mask (another BMP) yourself.
Or, load the picture from disk at runtime.
OK, but wouldn't another fix be to create a new mask for the image?
I mean I could create a new mask image at runtime which looks at the source picture and adds black pixels for none blue areas?
Would that work?
If so then this may slow down the app a little when the window was loading but not increase the exe size.
Sure, that'd work (but be fairly slow, I'd suspect). I still recommend just using a BMP and setting Transparent = white if you can get away with it though.
I'd be really nice to have better transparency support. I use PNG's a lot, thanks to their small file size and transparency support. Unfortunately, with I then go and use these images, I have to hope the bmp+mask works right, and it doesn't always. I get white borders and other nastiness. The TrayApp plugin that I use in 5.5 for the system tray allows for PNG's that where embedded and did the correct transparency. But when I tried building with 06r4 recently, it had no transparency, and even with a good mask for it, it still doesn't look right, with white borders. Note, that the mask is a B/W copy of the PNG's alpha layer.
Hi Aaron,
Hope you can make it for the next release. ;-)
It would make our work a lot easier, because the most icon's you get on the market are saved as PNG with alpha. It's not always easy to make mask for differend background colors without lossing quality.
Greetings
Richard