[Qt-interest] how should QPixmap alpah mask image should look like ?
Gabriel M. Beddingfield
gabrbedd at gmail.com
Thu May 20 06:05:26 CEST 2010
On Thu, 20 May 2010, Meir Yanovich wrote:
> Hello
> i tried to search the web for examples on how should the alpha mask image
> should look like , but i didn't found any examples.
Not sure what you mean. If talking about using QWidget::setMask()
then here is an example:
if(_compositing) {
QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawRoundedRect( QRectF( 0, 0, w, h),
border_rad+thickline/2.0,
border_rad+thickline/2.0 );
QBitmap bmp = QBitmap::fromImage(mask_img);
setMask( bmp );
}
Source: [0]
This creates a white image (.fill(0xff)) and then fills in black
whereever I want the widget to show through.
The resulting "main window" looks like [1]. When you run the
application, the user sees rounded corners on the widget, and whatever
is behind it will show through. However, there are also some specific
window flags you have to set for this to work.
> say i have the Gimp image editor .what should be in the alpha image map
> so it could work with the QPixmap ?
> ( i have no idea on images and graphics )
It's a black and white (monochrome) bitmap. Black is your
drawing space. White is your mask (as in "masking tape").
-gabriel
[0] http://gitorious.org/stretchplayer/stretchplayer/blobs/master/src/PlayerWidget.cpp
line 295
[1] http://www.teuton.org/~gabriel/stretchplayer/
More information about the Qt-interest-old
mailing list