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.l SampleSize;
long *pBuffer = (long *)malloc(nBuffe rSize);
HANDLE fh;
BITMAPFILEHEADE R bmfh;
DWORD nWritten;
memset(&bmfh, 0, sizeof(bmfh));
bmfh.bfType = ('M' << 8) | 'B';
bmfh.bfSize = sizeof(bmfh) + sizeof(BITMAPIN FOHEADER) + nBufferSize;
bmfh.bfOffBits = sizeof(bmfh) + sizeof(BITMAPIN FOHEADER);
fh = CreateFile(L"sa mple.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_ NORMAL, NULL);
WriteFile(fh, &bmfh, sizeof(bmfh), &nWritten, NULL);
WriteFile(fh, &pVideoInfoHead er->bmiHeader, sizeof(BITMAPIN FOHEADER),
&nWritten, NULL);
WriteFile(fh, pBuffer, nBufferSize, &nWritten, NULL);
CloseHandle(fh) ;
GlobalFreePtr(& pVideoInfoHeade r);
GlobalFree(&bmf h);
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.l SampleSize;
long *pBuffer = (long *)malloc(nBuffe rSize);
HANDLE fh;
BITMAPFILEHEADE R bmfh;
DWORD nWritten;
memset(&bmfh, 0, sizeof(bmfh));
bmfh.bfType = ('M' << 8) | 'B';
bmfh.bfSize = sizeof(bmfh) + sizeof(BITMAPIN FOHEADER) + nBufferSize;
bmfh.bfOffBits = sizeof(bmfh) + sizeof(BITMAPIN FOHEADER);
fh = CreateFile(L"sa mple.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_ NORMAL, NULL);
WriteFile(fh, &bmfh, sizeof(bmfh), &nWritten, NULL);
WriteFile(fh, &pVideoInfoHead er->bmiHeader, sizeof(BITMAPIN FOHEADER),
&nWritten, NULL);
WriteFile(fh, pBuffer, nBufferSize, &nWritten, NULL);
CloseHandle(fh) ;
GlobalFreePtr(& pVideoInfoHeade r);
GlobalFree(&bmf h);
free(pBuffer);
nBufferSize = NULL;
Comment