Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages
Started by Chawalit K.
Mon, 18 Nov 2002 17:22
What wrong in this code? :(
Author: Chawalit K.
Date: Mon, 18 Nov 2002 17:22
Date: Mon, 18 Nov 2002 17:22
31 lines
1939 bytes
1939 bytes
DirectShow Case:
I try to grabber image frame with SampleGrabber and I have array of byte. I
want save it to file.
But I can see only black color in my image file.
Please show me. What wrong in this code? :-(
long cbBuffer = 320*240*3;
HRESULT hr = NULL;
byte *pBuffer = (byte*)malloc(cbBuffer);
hr = vcap.pGrabber->GetCurrentBuffer(&cbBuffer, (long*)pBuffer);
if(FAILED(hr)) {
return;
}
AM_MEDIA_TYPE mt;
BITMAPINFO BmpInfo;
hr = vcap.pGrabber->GetConnectedMediaType(&mt);
if FAILED(hr) return;
VIDEOINFOHEADER *pVideoHeader = (VIDEOINFOHEADER*)mt.pbFormat;
CopyMemory(&BmpInfo.bmiHeader, &pVideoHeader->bmiHeader,
sizeof(BITMAPINFOHEADER));
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->HandleType = bmDIB;
bmp->Handle = CreateDIBSection(0, &BmpInfo, DIB_RGB_COLORS,
(void**)&pBuffer, NULL, 0);
bmp->SaveToFile("c:\\test" + (AnsiString)aa + ".bmp");
Chawalit K.
Thailand
Re: What wrong in this code? :(
Author: Chawalit K.
Date: Mon, 18 Nov 2002 17:43
Date: Mon, 18 Nov 2002 17:43
70 lines
3187 bytes
3187 bytes
Oop! :-p
I know that what wrong is me. ha ha
this right
long cbBuffer = 320*240*3;
HRESULT hr = NULL;
byte *pBuffer = (byte*)malloc(cbBuffer);
AM_MEDIA_TYPE mt;
BITMAPINFO BmpInfo;
HBITMAP hBitmap = NULL;
hr = vcap.pGrabber->GetConnectedMediaType(&mt);
if FAILED(hr) return;
VIDEOINFOHEADER *pVideoHeader = (VIDEOINFOHEADER*)mt.pbFormat;
CopyMemory(&BmpInfo.bmiHeader, &pVideoHeader->bmiHeader,
sizeof(BITMAPINFOHEADER));
hBitmap = CreateDIBSection(0, &BmpInfo, DIB_RGB_COLORS,
(void**)&pBuffer, NULL, 0);
hr = vcap.pGrabber->GetCurrentBuffer(&cbBuffer, (long*)pBuffer);
if(FAILED(hr)) {
return;
}
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->Handle = hBitmap;
bmp->SaveToFile("c:\\test" + (AnsiString)aa + ".bmp");
Image1->Canvas->Draw(0,0,bmp);
delete bmp;
DeleteObject(hBitmap);
Thanks
Chawalit K.
Thailand
"Chawalit K." <q0022@softhome.net> wrote in message
news:3dd921f1@newsgroups.borland.com...
> DirectShow Case:
> I try to grabber image frame with SampleGrabber and I have array of byte.
I
> want save it to file.
> But I can see only black color in my image file.
> Please show me. What wrong in this code? :-(
>
> long cbBuffer = 320*240*3;
> HRESULT hr = NULL;
> byte *pBuffer = (byte*)malloc(cbBuffer);
> hr = vcap.pGrabber->GetCurrentBuffer(&cbBuffer, (long*)pBuffer);
> if(FAILED(hr)) {
> return;
> }
>
> AM_MEDIA_TYPE mt;
> BITMAPINFO BmpInfo;
>
> hr = vcap.pGrabber->GetConnectedMediaType(&mt);
> if FAILED(hr) return;
> VIDEOINFOHEADER *pVideoHeader = (VIDEOINFOHEADER*)mt.pbFormat;
> CopyMemory(&BmpInfo.bmiHeader, &pVideoHeader->bmiHeader,
> sizeof(BITMAPINFOHEADER));
>
> Graphics::TBitmap *bmp = new Graphics::TBitmap();
> bmp->HandleType = bmDIB;
> bmp->Handle = CreateDIBSection(0, &BmpInfo, DIB_RGB_COLORS,
> (void**)&pBuffer, NULL, 0);
> bmp->SaveToFile("c:\\test" + (AnsiString)aa + ".bmp");
>
> Chawalit K.
> Thailand
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads