Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Simple Q: What is a mask?

Posted on 1998-12-06
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.
Question by:Minos111998
  • 3
  • 2

Expert Comment

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.

Author Comment

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?

Accepted Solution

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.

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center


Expert Comment

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?


Author Comment

ID: 1448449

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?


Expert Comment

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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

791 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