🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #756

What wrong in this code? :(

#756
From: Chawalit K.
Date: Mon, 18 Nov 2002 17:22
31 lines
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
Technical Details
Message-ID: <3dd921f1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,6689030411e53bec,start
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2002-11-18 09:50:04 PST
From: "Chawalit K." <q0022@softhome.net>
Newsgroups: borland.public.cppbuilder.multimedia
Subject: What wrong in this code?  :(
Date: Tue, 19 Nov 2002 00:22:44 +0700
Lines: 33
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 203.113.80.14
Message-ID: <3dd921f1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1037640177 203.113.80.14 (18 Nov 2002 09:22:57 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail