Solved

Simple Q: What is a mask?

Posted on 1998-12-06
6
159 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now