开发者

How do I erase a portion of a bitmap in Qt?

Any i开发者_如何学JAVAdea on how to erase a portion of a bitmap just like Android's PorterDuff Mode? I am creating an application like Paint, and I don't know how to erase the drawings I have written using the pen.

Any idea regarding this one? Thank you!


I suggest you use the QPainter class which can perform various drawing operations on a QBitmap (more precisely: it draws on a QPaintDevice, from which QBitmap derives).

Among the various operations of the painter, there is QPainter::eraseRect() which can erase a portion of a QBitmap.

This is the way you use it:

QBitmap b;
QPainter p( &b );
p.eraseRect( x, y, w, h ); // With x, y, w and h defining the portion
                           // of your bitmap you want to erase
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜