[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Masking Problem

Posted on 2004-10-26
3
Medium Priority
?
244 Views
Last Modified: 2010-05-02
I am using BitBlt to mask an image:

lngRet = BitBlt(canvas.hDC, RealX, RealY, wMask.ScaleWidth, wMask.ScaleHeight, wMask.hDC, 0, 0, vbMergePaint)
lngRet = BitBlt(canvas.hDC, RealX, RealY, wPawn.ScaleWidth, wPawn.ScaleHeight, wPawn.hDC, 0, 0, vbSrcAnd)


where wPawn is the image I want and wMask is the mask of wPawn. However, I am having a hard time, i've tried different colors as the mask and had weird results. I've tried the mask as Pink with the Good Area as black and had the best results. But I still see the pink area!


Help.
Brian
0
Comment
Question by:BrianGEFF719
[X]
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
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
List244 earned 750 total points
ID: 12417752
BitBlt Canvas.hDC, 0, 0, Wmask.ScaleWidth, Wmask.ScaleHeight, Wmask.hDC, 0, 0, vbSrcAnd
BitBlt Canvas.hDC, 0, 0, Wmask.ScaleWidth, Wmask.ScaleHeight, Wpawn.hDC, 0, 0, vbSrcPaint

This will work if your mask is black/white (White where transparent
black where opaque) Then your other image should be black where
transparent. Your mask should always be white/black though. Not
colorful.
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 12652278
Quick late followup, I've seen masks be pink, whats that about?

-Brian
0
 
LVL 8

Expert Comment

by:List244
ID: 12655934
Many times you will see images with a pink background.
In the games they will appear transparent. However, as
far as I am aware, this can not be done using BitBlt. These
are not truly masks, but the images. The thing you miss out
on here, is the fact that the color pink becomes a color you
can not use in your picture. Using BitBlt you can use ANY
color, because of the mask, which tells where to be transparent.

Here is how the pink would work.

For X = 0 to PictureWidth
 For Y = 0 to PictureHeight
  If Not (ColorOfPixel = Pink) Then
   SetPixel DrawTo.DC, X,Y, GetPixel(PictureDC,X,Y)
  End If
 Next Y
Next X

A way you could do this is:

Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean

This function is similar to BitBlt, except now rather than the raster-operation
code, it wants to know what color to ignore.

ANY color can be made transparent, pink is used as it is easy to get along
without.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

656 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