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
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
  • 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.

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.


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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

623 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