| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 7 | |
My app can display a variety of different file types(about 20 different
types), with each type have its own unique icon. The icons are shown as
QListBoxItems, coming from XPM data.
My dilemma is that I will soon be introducing version control into my
app so I need to show various "states" for each of the file types. I
don't want to create a separate icon for each combination, but would
rather like programmatically create new "composite" icons by combining
the "state" icons(ie file is locked, file is checked out, etc) with the
various file type icons.
It seems the way to do this is to use the copyBlt function. What I don't
know is how to do the blt so the transparent areas of the "state" icons
are preserved. As a trivial example, if I have the following "state"
icon, how do I get the four corners to be transparent after the
copy(they don't obscure the pixels in the "file type" icon)?
static const char *state_xpm[] = {
"3 3 2 1",
". c None",
"x c #ff0000",
".x.",
"xxx",
".x."};
Here's my guess at the code I need, please "fill in the blanks".
QPixmap fileType(fileType_xpm);
QPixmap state(state_xpm);
// WHAT AM I MISSING - A MASK OF SOME KIND ????
copyBlt(fileType,0,0, state,0,0,3,3);
Thanks in advance for any help,
John
PS I'm using Qt 3.3.3
On Tuesday 26 October 2004 03:15, Vella, John wrote: > It seems the way to do this is to use the copyBlt function. What I don't > know is how to do the blt so the transparent areas of the "state" icons > are preserved. > Here's my guess at the code I need, please "fill in the blanks". > > QPixmap fileType(fileType_xpm); > QPixmap state(state_xpm); > // WHAT AM I MISSING - A MASK OF SOME KIND ???? > copyBlt(fileType,0,0, state,0,0,3,3); Yes, you are missing a mask! Check out http://doc.trolltech.com/3.3/qpixmap.html#setMask. Most often, I use a second picture in just black and white that acts as the mask Regards, André -- [ signature omitted ]
Attachment:
pgp4D0ngKwyny.pgp
Description: PGP signature
-----Original Message-----
From: Vella, John
Sent: Wednesday, October 27, 2004 8:59 AM
To: 'a.t.somers@xxxxxxxxxxxxxxxxxx'
Subject: RE: Need help programmatically combining two pixmaps
Do you have an example of what the mask image definition would look like? I would like to create the images as XPMs so I can keep them within the source file. So I would need to know how to define the mask as an XPM. Would something like this work:
const char *my_mask[] = {
"3 3 2 1",
"x c #000000",
". c #ffffff",
".x.",
"xxx",
".x."};
Thanks for your help,
John
-----Original Message-----
From: owner-qt-interest@xxxxxxxxxxxxx [mailto:owner-qt-interest@xxxxxxxxxxxxx] On Behalf Of André Somers
Sent: Tuesday, October 26, 2004 1:34 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Need help programmatically combining two pixmaps
On Tuesday 26 October 2004 03:15, Vella, John wrote:
> It seems the way to do this is to use the copyBlt function. What I
> don't know is how to do the blt so the transparent areas of the
> "state" icons are preserved.
> Here's my guess at the code I need, please "fill in the blanks".
>
> QPixmap fileType(fileType_xpm);
> QPixmap state(state_xpm);
> // WHAT AM I MISSING - A MASK OF SOME KIND ????
> copyBlt(fileType,0,0, state,0,0,3,3);
Yes, you are missing a mask! Check out
http://doc.trolltech.com/3.3/qpixmap.html#setMask. Most often, I use a second picture in just black and white that acts as the mask
Regards,
André
--
[ signature omitted ]