monoceres
June 23rd, 2009, 06:13 PM
Hi!
I'm developing a DirectShow player and I wish to have the ability to grab individual frames during playback. This is done with the IVMRWindowlessControl9::GetCurrentImage method. It returns a DIB and it works really good if I just add a BITMAPFILEHEADER and dump it to a file.
However when I try to create a DDB from it (to do further processing) the image always end up wrong somehow, this for example:
ic->pVMRControl->GetCurrentImage(&lpCurrImage))
LPBITMAPINFOHEADER pdib = (LPBITMAPINFOHEADER) lpCurrImage;
HDC dc=GetDC(NULL);
BITMAPINFO bmi;
ZeroMemory(&bmi, sizeof(BITMAPINFO));
CopyMemory(&(bmi.bmiHeader), pdib, sizeof(BITMAPINFOHEADER));
HBITMAP hBitmap = CreateDIBitmap(dc, pdib, CBM_INIT,
pdib+pdib->biSize, &bmi, DIB_PAL_COLORS );
Makes the image uhm, the right half is moved to the left half and vice versa.
So I tried CreateBitmapInstead, like this:
HBITMAP hBitmap = CreateBitmap(pdib->biWidth,(pdib->biHeight),pdib->biPlanes,pdib->biBitCount,
lpCurrImage + ( pdib->biSize + DibPaletteSize(pdib)));
But that made the image turn out upside down.
Please help, going insane over here!
I'm developing a DirectShow player and I wish to have the ability to grab individual frames during playback. This is done with the IVMRWindowlessControl9::GetCurrentImage method. It returns a DIB and it works really good if I just add a BITMAPFILEHEADER and dump it to a file.
However when I try to create a DDB from it (to do further processing) the image always end up wrong somehow, this for example:
ic->pVMRControl->GetCurrentImage(&lpCurrImage))
LPBITMAPINFOHEADER pdib = (LPBITMAPINFOHEADER) lpCurrImage;
HDC dc=GetDC(NULL);
BITMAPINFO bmi;
ZeroMemory(&bmi, sizeof(BITMAPINFO));
CopyMemory(&(bmi.bmiHeader), pdib, sizeof(BITMAPINFOHEADER));
HBITMAP hBitmap = CreateDIBitmap(dc, pdib, CBM_INIT,
pdib+pdib->biSize, &bmi, DIB_PAL_COLORS );
Makes the image uhm, the right half is moved to the left half and vice versa.
So I tried CreateBitmapInstead, like this:
HBITMAP hBitmap = CreateBitmap(pdib->biWidth,(pdib->biHeight),pdib->biPlanes,pdib->biBitCount,
lpCurrImage + ( pdib->biSize + DibPaletteSize(pdib)));
But that made the image turn out upside down.
Please help, going insane over here!