The open source LPub is an application that lets you publish instructions for LEGO models from LDraw data, primarily as PDF files. One of its nice additional features is the export of pages as PNG files. While functional, this export doesn’t properly support transparency. Since PNG files do support transparency, this is a bit irritating.
There is UI to set the background, and it has a “none” choice, but using it results in a solid white background instead of a transparent (or, worse in older versions, to a solid black background). Another choice is to use a background image, so you can try to fake out the application by setting the background image to a PNG that is nothing but transparent. The program allows this, but when you export the result, you see the art for each page layered on top of each other (clearly, the app is not clearing a buffer between pages).
Over a year ago, I submitted bugs for both of these problems to the LPub team (here and here). As of this writing, neither of them have been assigned to anyone, much less fixed.
So, I decided to fix it myself. Getting the code downloaded and built in XCode took several hours, and would have taken even longer had I not found the very useful “Compile LPub4 using XCode on Mac OS X” post by Mark from More than just bricks. I had to tweak a couple other things to get it to work, but nothing too drastic.
Knowing nothing about how the code worked and very little about Qt, the GUI package it uses, it took a couple of hours figure out where to make the fix and getting it working properly. The main trick is to add
QPixmap.fill(Qt::transparent) in a key place in
Gui::exportAs. The rest of the changes are just slight alterations to the UI. Not many changes needed, and maybe I missed something, but seems to work for me.
A patch containing my changes was made against the current head of the project’s CVS tree. I have submitted it to the LPub team. I will update this post if it gets included in a release.