PDA

View Full Version : QBitmap does not scale correctly with QPainter



macaco
8th August 2008, 11:40
Hi all. I'm having some trouble with the following. I have a widget with a custom (non-rectangular) background, and I need to set its mask every time it's resize. Since the corner pieces stay the same size, and only the middle parts stretch, I need to draw the background bit by bit. Since I don't want to call createHeuristicMask during the paint routine, I call it in the beginning with my base background image, so that I have two images of the same size - one is the background image, the other is the QBitmap mask I generated.

In the actual drawing routine, I paint the background onto the widget using one QPainter, and another QPainter does exactly the same drawing routine with the QBitmap onto a QBitmap buffer. This buffer becomes the widget's new mask.

The problem comes in the middle areas that need to be stretched depending on the new size of the widget. This works great for the background pixmap, but for some reason it doesn't behave for the QBitmap. It seems to spread the same number of opaque pixels across a larger area so that what was once a solid shape ends up looking like noise.

This is on Mac OS X, though I believe the same happens on Win32 (will try again today).

Thanks!