HRESULT CDVGraph::GetBitmapBits(double StreamTime, long *pBufferSize, char *pBuffer, long Width, long Height)
{
HRESULT hr;
long size;
hr = m_pIMediaDet->GetBitmapBits(0, &size, 0, Width, Height);
if (SUCCEEDED(hr)) //可以截取.
{
char *Buffer = NULL;
Buffer = new char[size];//理解,分配这么长的缓冲区.Buffer为其指针.------------>无法赋值!!
if (!Buffer)
return E_OUTOFMEMORY;
try //我认为这一步的意思是指BUFFER是否正确地指向缓冲区.
{
hr = m_pIMediaDet->GetBitmapBits(0, &size, Buffer, Width, Height);//存入此指针所指向的缓冲区.
}
catch (...) {
delete [] Buffer;
throw;
}
if (SUCCEEDED(hr))
{
BITMAPINFOHEADER *bmih = (BITMAPINFOHEADER*)Buffer;
HDC hdcDest = GetDC(0);
// Find the address of the start of the image data.
void *pData = Buffer + sizeof(BITMAPINFOHEADER);
// Note: In general a BITMAPINFOHEADER can include extra color
// information at the end, so calculating the offset to the image
// data is not generally correct. However, the IMediaDet interface
// always returns an RGB-24 image with no extra color information.