Apply mask to pixmap_from_file

Asked by Alex K

What is the syntax for adding a mask to the pixmap_from_file command?

<pixmap_from_file ... >
   <alpha_mask mask="mask" />
</pixmap_fro_file>

doesn't work, nor does

<pixmap_from_file ... mask="mask" />

Question information

Language:
English Edit question
Status:
Solved
For:
DockbarX Edit question
Assignee:
No assignee Edit question
Solved by:
Alex K
Solved:
Last query:
Last reply:
Revision history for this message
Matias Särs (msevens) said :
#1

<pixmap_from_file name="NAME_OF_MASK" file="NAME_OF_FILE" /> is what you should use. Masks are normal pixmaps. You just use them as masks later in the config file.

Revision history for this message
Alex K (levviathor) said :
#2

That's not what I meant. I know how to apply a mask to a pixmap created with the <pixmap></pixmap> command, like this:

<pixmap name="active_bg">
     <fill color="#FFFFFF" opacity="35" />
     <alpha_mask mask="mask-main" />
</pixmap>

Here, the mask is applied to active_bg in the command that creates it. How would I apply a mask to an existing pixmap, namely one that has *already* been created with <pixmap_from_file />, though I have nothing against putting a mask="mask" command in pixmap_from_file.

Perhaps something like,

<pixmap name="masked_image">
     <pixmap_from_file file="image.png"
     <alpha_mask mask="mask" />
</pixmap>

would work?

Revision history for this message
Matias Särs (msevens) said :
#3

You answered your own question.

Is there a reason why you want to add the mask this way instead of just adding the mask to the png directly in gimp? It probably doesn't matter at all in reality but theoreticly this could slow things down slightly, since some of the algorithms used by alpha_mask are called slow in gtk-python documentation (but they probably mean for bigger images that icons).

Revision history for this message
Alex K (levviathor) said :
#4

You're right--just editing the image file itself would be better.

However, masks give a greater amount of flexibility, and it's just nice to know