How to use MaskBlt operation in GDI+

S

sekarhcl

Hi,
I want to copy some portion of a bitmap(source bitmap) to another
bitmap(destination bitmap) using a reference mask bitmap. This task can
be acomplished in GDI using MaskBlt function. Is there any such
function in GDI+ for doing the same?

I saw Bob's "Extract a region from a bitmap" article. In that we are
creating region based on the given color and setting it as the region
for the form.
But in my case, I have the reference mask bitmap. If a particular pixel
in the mask bitmap is "WHITE", the corresponding pixel value available
in the source bitmap should be copied to destination bitmap. Otherwise,
it should be ignored. This process sould be repeated for the entire
image.

If anyone knows, kindly update.
 
M

Michael Phillips, Jr.

Why not use P-INVOKE MaskBlt?

This function is performed by the device driver, if the operating
system supports it. It is the optimal method for doing what you
want!
 
S

sekarhcl

What is this P-INVOKE?

I just want to know how to implement MaskBlt functionality using GDI+?
In GDI, I made some drawings in the device context and so I used
MaskBlt function for transferring images.
Now I am drawing in GDI+'s Graphics objects. So how to apply the same
functionality in GDI+?
 
M

Michael Phillips, Jr.

What is this P-INVOKE?

Platform Invoke
[DllImport("gdi32.dll")]
static extern bool MaskBlt(IntPtr hdcDest, int nXDest, int nYDest, int
nWidth,
int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, IntPtr hbmMask, int
xMask,
int yMask, uint dwRop);

Now I am drawing in GDI+'s Graphics objects. So how to apply the same
functionality in GDI+?


There is no gdi+ equivalent. Use MaskBlt by adding the above declaration
to your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top