One of the reasons for choosing .NET as a development platform has always been platform independence. In many ways, .NET indeed offers this. But there are some issues and the following article shows one of them.
A few days ago, one of our customers submitted an issue for PDFRasterizer.NET. A particular document rendered alright on Windows XP, but not on Windows 7.
Our software however, has no notion whatsoever about these different systems. It just renders to whatever Graphics instance .Net offers us. So this had to be an issue in .NET itself, and one that only manifests itself on particular Windows platforms.
When one of our developers picked this up, I asked him to focus on the newer Windows systems. Windows XP is quickly becoming obsolete now Microsoft is going to stop supporting it. If a fix was going to break rendering on Windows XP, then so be it.
It turned out that the problem was related to indexed images on 64-bit systems, If there are semi-transparent colors in the color table of an indexed image, these are sometimes rendered as an opaque color. Often white or some other basic color. Interestingly, the problem only occurred if the alpha value of a color was between zero and 240. We tried to nail this down further, but we were unable to discover any particular logic in it.
Now, this looks fairly nasty, but the solution to this issue was simple. If we encounter indexed images with these transparent colors, we simply convert it to a non-indexed variant. This is somewhat less efficient, because the entire image will need to be converted. Luckily, this situation does not happen all that often, so it is hardly noticeable in the grand scheme of things.
And for what it is worth, it also works on XP.