Jump to content
  • Advertisement
Sign in to follow this  
DinGY

creating mask

This topic is 4514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The mask is not created, why?.
        case WM_PAINT:
            PAINTSTRUCT ps;
            HDC hdc;
            BITMAP bmp;

            hdc = BeginPaint(hwnd, &ps);

            HBITMAP hbmMem = (HBITMAP)LoadImage(GetModuleHandle(NULL),
            "win.bmp", IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

            HDC hdcMem = CreateCompatibleDC(NULL);

            SelectObject(hdcMem, hbmMem);
            GetObject(hbmMem, sizeof(BITMAP), (LPVOID)&bmp);


            HBITMAP hbmMask = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL);
            HDC hdcMask1 = CreateCompatibleDC(NULL);
            HDC hdcMask = CreateCompatibleDC(NULL);

            SelectObject(hdcMask, hbmMem);
            SelectObject(hdcMask1, hbmMask);

            SetBkColor(hdcMask, RGB(255, 255, 255));

            BitBlt(hdcMask1, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcMask, 0, 0, SRCCOPY);
            BitBlt(hdcMask, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcMask1, 0, 0, SRCINVERT);

            BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcMask, 0, 0, SRCCOPY);

            DeleteDC(hdcMem);
            DeleteDC(hdcMask1);
            DeleteDC(hdcMask);

            EndPaint(hwnd, &ps);

            break;


Share this post


Link to post
Share on other sites
Advertisement
What you're doing in that statement is loading "win.bmp" every time the window is painted. What you should do is load it once, store it for later use, and then just draw it every WM_PAINT event. Also remember to delete the image when you're done using it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!