Bitmap with rounded corners

160 views Asked by At
    GetWindowRect(hWnd, &wnd);
    hdc = BeginPaint(hWnd, &ps);
    hdcMem = CreateCompatibleDC(hdc);

    for (int i = 0; i < n; ++i)
    {
        HRGN rgn = CreateRoundRectRgn(0, 0, CARD_WIDTH, CARD_HEIGHT, 7, 7);
        SetWindowRgn(cards[info[i].card], rgn, TRUE);
        oldBitmap = SelectObject(hdcMem, cards[info[i].card]);
        GetObject(cards[info[i].card], sizeof(bitmap), &bitmap);
        BitBlt(hdc, info[i].pos.x, info[i].pos.y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
        SelectObject(hdcMem, oldBitmap);
    }

I have problem with cutting corners for bitmap picture.

1

There are 1 answers

1
user2962433 On BEST ANSWER
GetWindowRect(hWnd, &wnd);
        hdc = BeginPaint(hWnd, &ps);
        hdcMem = CreateCompatibleDC(hdc);
        for (int i = 0; i < n; ++i)
        {
            HRGN rgn = CreateRoundRectRgn(info[i].pos.x, info[i].pos.y, info[i].pos.x + CARD_WIDTH, info[i].pos.y + CARD_HEIGHT, 7, 7);
            SelectClipRgn(hdc, rgn);
            oldBitmap = SelectObject(hdcMem, cards[info[i].card]);
            GetObject(cards[info[i].card], sizeof(bitmap), &bitmap);
            BitBlt(hdc, info[i].pos.x, info[i].pos.y, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);
            SelectObject(hdcMem, oldBitmap);
        }

Thanks to Jonathan Potter.