Re-sizing Image Using CDC

538 Views Asked by At

I am trying to write a component for my program to re-size image frames from a video. The current code is called, which takes the CDC from the current frame.

void showImageFrame(LPSTR info)
{
    BITMAPINFOHEADER * pInfo = (BITMAPINFOHEADER *)info;
    CDC* pDC=pWnd=GetDlgItem(IDCFrame)->GetDC();
    CRect rect;
    pWnd->GetClientRect(&rect);
    SetDIBitsToDevice(pDC->GetSafeHdc(), 0, 0, rect.Width(), rect.Height(), 0, 0, 0, pInfo->biHeight, info + *(LPDWORD)info, (LPBITMAPINFO) pInfo, DIB_RGB_COLORS);
    pDC->StretchBlt(0,0,200,200,pDC,0,0,rect.Width(),rect.Height(),SRCCOPY);
}

The StretchBlt does re-size the image displayed at the current frame, but it retains the larger image from the SetDIBitsToDevice. Is there any way to remove the image of the SetDIBitsToDevice, or do this in a more efficient way? I am trying to re-size the image to 200x200.

Using the current code above, I get the following output. enter image description here

Thanks!

https://i.stack.imgur.com/dWXRZ.png

1

There are 1 best solutions below

2
On

One quick way. Create a blank (white) image and stretch it over the original image, then StretchBlt your resized image.