Saturday, August 06, 2005

[Qt] bitBlt to QPixmap with XorROP broken ?

Hi,

I have some code using bitBlt to a QPixmap, which has worked for several
years. But since some days (update to Qt-3.3.4 ?) the ROP parameter of
the bitBlt seems to be ignored.

My code holds one QPixmap to avoid flicker and copies two QPixmaps into
it, using CopyROP for the background (layer1) and XorROP for the layer2.
Then the pixmap is bitBlt'ed to the widget.

I stripped it down to the following simple example code:
------------------------------------------------
void MyWidget::paintEvent(QPaintEvent *)
{
QPainter p;
QPixmap pixmap(size());
QPixmap layer1(size());
QPixmap layer2(size());

layer1.fill(green);
p.begin(&layer1);
p.setPen(red);
p.drawLine(0, 0, width(), height());
p.end();

layer2.fill(black);
p.begin(&layer2);
p.setPen(white);
p.drawRect(width()/4, height()/4, width()/2, height()/2);
p.end();

// this stopped working, I always see only layer2
// it seems that Qt::XorROP is ignored and CopyROP is used !!!???
bitBlt(&pixmap, 0, 0, &layer1, 0, 0, -1, -1, Qt::CopyROP);
bitBlt(&pixmap, 0, 0, &layer2, 0, 0, -1, -1, Qt::XorROP);
bitBlt(this, 0, 0, &pixmap);
// shows a black screen with a white rectangle (== layer2) :-(

// this works, but flickers, and this is *NOT* what I want
// bitBlt(this, 0, 0, &layer1, 0, 0, -1, -1, Qt::CopyROP);
// bitBlt(this, 0, 0, &layer2, 0, 0, -1, -1, Qt::XorROP);
// shows a green screen, red diagonal line + red recangle
}
------------------------------------------------

What is going wrong here, is this problem already known?

Thomas

0 Comments:

Post a Comment

<< Home