-1

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

elimad
  • 1,132
  • 1
  • 15
  • 27

1 Answers1

0

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

Gavin Simpson
  • 2,766
  • 3
  • 30
  • 39
  • Do you know of any way to accomplish it without using any other images/videos? – xSukiyaki Oct 15 '14 at 06:56
  • ' HBITMAP CScene::saveDCtoBuffer(HDC hdc, HINSTANCE hInst) { HBITMAP tBitmap; HDC hTargetDC = CreateCompatibleDC(hdc); tBitmap = CreateCompatibleBitmap(hdc,width,height-TOOLBARHEIGHT-STATUSBARHEIGHT); SelectObject(hTargetDC,tBitmap); BitBlt(hTargetDC, 0, 0, width, height-TOOLBARHEIGHT-STATUSBARHEIGHT, hdc, 0, TOOLBARHEIGHT, SRCCOPY); DeleteDC(hTargetDC); return tBitmap; } ' This is not MFC, but is should help you. Once you have the new image use "Rectangle" and draw a white polygon over the original image, then bitblt the image as copied with the function. – Gavin Simpson Oct 15 '14 at 07:26