B
botched
I have the following code w/is working like a champ. Problem is I dont want
to write it to file yet. I would rather write it to memory and pass a
HBITMAP handle back to the calling process. So far I my attempt has only
yeilded memory issues. Can someone point me to the right direction.
long nBufferSize = am_media_type.lSampleSize;
long *pBuffer = (long *)malloc(nBufferSize);
HANDLE fh;
BITMAPFILEHEADER bmfh;
DWORD nWritten;
memset(&bmfh, 0, sizeof(bmfh));
bmfh.bfType = ('M' << 8) | 'B';
bmfh.bfSize = sizeof(bmfh) + sizeof(BITMAPINFOHEADER) + nBufferSize;
bmfh.bfOffBits = sizeof(bmfh) + sizeof(BITMAPINFOHEADER);
fh = CreateFile(L"sample.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(fh, &bmfh, sizeof(bmfh), &nWritten, NULL);
WriteFile(fh, &pVideoInfoHeader->bmiHeader, sizeof(BITMAPINFOHEADER),
&nWritten, NULL);
WriteFile(fh, pBuffer, nBufferSize, &nWritten, NULL);
CloseHandle(fh);
GlobalFreePtr(&pVideoInfoHeader);
GlobalFree(&bmfh);
free(pBuffer);
nBufferSize = NULL;
to write it to file yet. I would rather write it to memory and pass a
HBITMAP handle back to the calling process. So far I my attempt has only
yeilded memory issues. Can someone point me to the right direction.
long nBufferSize = am_media_type.lSampleSize;
long *pBuffer = (long *)malloc(nBufferSize);
HANDLE fh;
BITMAPFILEHEADER bmfh;
DWORD nWritten;
memset(&bmfh, 0, sizeof(bmfh));
bmfh.bfType = ('M' << 8) | 'B';
bmfh.bfSize = sizeof(bmfh) + sizeof(BITMAPINFOHEADER) + nBufferSize;
bmfh.bfOffBits = sizeof(bmfh) + sizeof(BITMAPINFOHEADER);
fh = CreateFile(L"sample.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(fh, &bmfh, sizeof(bmfh), &nWritten, NULL);
WriteFile(fh, &pVideoInfoHeader->bmiHeader, sizeof(BITMAPINFOHEADER),
&nWritten, NULL);
WriteFile(fh, pBuffer, nBufferSize, &nWritten, NULL);
CloseHandle(fh);
GlobalFreePtr(&pVideoInfoHeader);
GlobalFree(&bmfh);
free(pBuffer);
nBufferSize = NULL;