[Qt-interest] how should QPixmap alpah mask image should look like ?

Meir Yanovich meiry242 at gmail.com
Thu May 20 08:09:32 CEST 2010


Thanks !!!

On Thu, May 20, 2010 at 7:05 AM, Gabriel M. Beddingfield <gabrbedd at gmail.com
> wrote:

>
>
> 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/<http://www.teuton.org/%7Egabriel/stretchplayer/>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100520/8deaea71/attachment.html 


More information about the Qt-interest-old mailing list