Solved

Simple Q: What is a mask?

Posted on 1998-12-06
6
162 Views
Last Modified: 2010-05-03
A very simple question.

When I talk about applying a mask to an image to make it transparent, is the mask the area which is going to be transparent, or is it the area of the image which is NOT going to be transparent. ???

I keep getting confused.
0
Comment
Question by:Minos111998
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1448445
Masks Overview
Masks enable you to hide and reveal parts of a layer and to apply special effects with precision. Masks can be created from selections, from images, from the luminance values of images, and from scratch.
A Mask can cover a layer completely or with varying levels of opacity. It is 256 grey scale image, and the levels of grey correspond to the levels of masking. Because it is grey scale, a mask can be saved into an alpha channel.
0
 

Author Comment

by:Minos111998
ID: 1448446
Sorry, so is the mask the area which will be seen finally, or is it the area which is going to be removed?
0
 
LVL 2

Accepted Solution

by:
trillo earned 30 total points
ID: 1448447
Actually a mask is not the area that will be removed, nor the area visible... it's none of them or both, depending on how you see them.

A mask is a bitmap that will act as an intermediate between the background and the actual bitmap. Masks are always monochrome.
By now you'll be saying..."yes, it's everything ok but that doesn't answer my quetion...". The fact is that the visible or non visible parts of the bitmap combination depends on which RASTER OPERATIONS you are using.

As an easy example look at this: Supose that pixels are given in RGB values, with 8 bits per color. Supose you have a red pixel RGB(255,0,0) in the background and you want to draw a blue pixel RGB(0,0,255) over it:
If you have a AND raster operation the result is:
red     11111111 00000000 00000000
blue    00000000 00000000 11111111
--------------------------------
result  00000000 00000000 00000000 = black pixel

but with a XOR raster operation:
red     11111111 00000000 00000000
blue    00000000 00000000 11111111
--------------------------------
result  11111111 00000000 11111111 = magenta (more or less) pixel
These are called binary raster operations and there are more than 10 different types

When you want to combine two bitmaps you use ternary raster operations, and there are a lot of them, but only a few are usefull in practice and they have special names.

When using masks, you use foreground and background ternary ratser operations. Remember that masks are monochrome so each pixel can only hve tow possible vaues: 1 or 0.... And here's the secret: A value of 1 in the mask specified indicates that the foreground raster operation code specified should be applied at that location. A value of 0 in the mask indicates that the background raster operation code specified by dwRop should be applied at that location.

Trillo
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 2

Expert Comment

by:trillo
ID: 1448448
I forgot to say that the ternary raster operations are so calles because they need: a source bitmap, a destination bitmap, and a brush. The Raster operation (ROP) code determines how they're combined.
What will you use this for?

Trillo
0
 

Author Comment

by:Minos111998
ID: 1448449
Bingo!

Now that really answered my question. Thanks. It's just that I seemed to have neglected that there are many ROPs available.

Thanks again.

And by the way, do you know if it is possible to somehow use a bitmap mask to generate a region? For clipping and so on, because the only region creating functions I know of uses RECTs or elipse and so on, eg CreateRectRgn, CreatePolygonRgnm CreateEllipticRgn etc.

Is it possible to use a bitmap mask to create a region instead?

0
 
LVL 2

Expert Comment

by:trillo
ID: 1448450
Actually I don't know how to use a bitmap as a region... but someone asked the same question one or two weeks ago and it's answered by someone, you can search in the <paq> questions, but I if I remember well I saw it in the C++ area.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question