Search code examples
bitblt

SRCCOPY removes transparancy from BITBLITTED IMAGE


BitBlt(meteor.main, 0, 0, meteor.img_width, meteor.img_height, meteor.image,  meteor.mask_x, meteor.mask_y, SRCAND);
BitBlt(meteor.main, 0, 0, meteor.img_width, meteor.img_height, meteor.image,  meteor.img_x,  meteor.img_y,  SRCPAINT);
BitBlt(buffer, 0, 0, 800, 600, meteor.main, 0, 0, SRCCOPY);

I know the first two bitblts make the transparancy, but the third removes it! What am I doing wrong here?


Solution

  • SrcCopy just flat copies everything from source to destination. Whatever was in your destination will now contain everything form your source.

    The way I usually do this is

    1) BitBlt(dest.hdc, dest.x, dest.y, width, height, srcMask.hdc, srcMask.x, srcMask.y, MergePaint)

    This will essentially cut a hole, in the form of the mask, into the destination.

    2) BitBlt(dest.hdc, dest.x, dest.y, width, height, src.hdc, src.x, src.y, SrcAnd)

    This basically overlays the source on top of the destination.

    If your source contains more image than what you want to overlay, you may first want to cut out all that is around your source first (before step 2.) using SrcPaint like this:

    1b) BitBlt(src.hdc, src.x, src.y, width, height, srcMask.hdc, srcMask.x, srcMask.y, SrcPaint)