🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

OTHER WAY

#521
From: Edward
Date: Wed, 03 Dec 2003 02:10
153 lines
4589 bytes
   I have two layers of programs "MY WEBCAMCAP" and "OTHER  PROGRAM WHERE I
SHOW THE VIDEO" first i try capture BMP and make other program read those
BMP after i try to put video direct on program.

        I trying to made a another way to my program work showing the image
direct on the DESKTOP but i have problem of FLICKER using:

       HWND hForm = GetDesktopWindow() ;

Using   HWND hForm = FindWindow("MYPROG",NULL);  doenst work.

ANY IDEIA?

My question is: How to capture video from a webcam without use FORM or
DESKTOP like Handle.






THE CODE





void __fastcall TFormPrincipal::FormCreate(TObject *Sender)
{

  AVICapDllHandle = LoadLibrary( "AVICAP32.DLL" );
  //  HWND hForm = FormPrincipal->Handle;
  HWND hForm = GetDesktopWindow() ;

  ctImg=0;
  FILE *arqSize;
  char strSize[10];
  AnsiString strAnsiSize;

  DeleteFile("SAIR.DAT");
  if(FileExists("SIZE.DAT"))
  {
    if((arqSize=fopen("SIZE.DAT","rt"))==NULL)
    {
      ShowMessage("Erro na abertura do Arquivo SIZE.DAT. Arquivo de
configura��o da WEBCAM!");
      Close();
    }
    fseek(arqSize,  SEEK_SET, 0);
    fgets(strSize, 12, arqSize);
    strAnsiSize = AnsiString(strSize);
    fclose(arqSize);

    tamXVL = strAnsiSize.SubString(1,strAnsiSize.AnsiPos("x")-1).ToInt();
    tamYVL =
strAnsiSize.SubString(strAnsiSize.AnsiPos("x")+1,strAnsiSize.Length()-(strAn
siSize.AnsiPos("x")+1) ).ToInt();
  }
  else
  {
    tamXVL=320;
    tamYVL=240;
  }
  if(AVICapDllHandle == 0)
  {
    MessageBox ( NULL, "LoadLibrary:\nAVICAP32.DLL not found.", "Error FS
002", MB_ICONSTOP );
  }
  hWndC = capCreateCaptureWindow("CamWin", WS_CHILD | WS_VISIBLE, 330, 250,
tamXVL, tamYVL, hForm, 0 );

  if(capDriverConnect(hWndC, 0))
  {
    if(capPreviewRate(hWndC, 100/3))
    {
      capPreviewScale(hWndC, TRUE);
      capPreview(hWndC, TRUE);
    }
  }
  TimerRefresh->Enabled = true;
}
//--------------------------------------------------------------------------
-



"Edward" <registrados@via-rs.net> escreveu na mensagem
news:3fc6476a$1@newsgroups.borland.com...
> Hi all
>
>     I using my code above to capture a imagem direct from my web cam and
> save into a BMP file but i need to resize the image and when i do that i
> have some problems i dont know what is happening.
>
>     In the future the program will be hinding from user so i cant show the
> FROM.
>
> Thanks
>
> Edward
>
>
>
>   CAPSTATUS CapStatus;
>   char str[12];
>
>   TimerRefresh->Enabled = false;
>   if(!FileExists("SAIR.DAT"))
>   {
>     if(ctImg>=20)
>     {
>       ctImg=0;
>     }
>     ctImg++;
>     sprintf(str,"web%03d.bmp",ctImg);
>
>     try
>     {
>       capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS));
>       capFileSaveDIB(hWndC, str);
>
>       Graphics::TBitmap *bmpOld = new Graphics::TBitmap();
>       Graphics::TBitmap *bmpNew = new Graphics::TBitmap();
>
>       bmpOld->LoadFromFile(str);
>       bmpNew->Width = tamXVL;
>       bmpNew->Height = tamYVL;
>       bmpNew->Canvas->StretchDraw(bmpNew->Canvas->ClipRect, bmpOld);
>
>       bmpNew->Assign(bmpNew);
>       bmpNew->SaveToFile(str);
>
>       delete bmpOld;
>       delete bmpNew;
>
>     }
>     catch (Exception &Ex)
>     {
>       MessageDlg("Exception type " + Ex.ClassName() + " returned error
> message: " + Ex.Message + "\r" + " in form " + this->ClassName(), mtError,
> TMsgDlgButtons() << mbOK, 0);
>       abort();
>     }
>   }
>   else
>   {
>     capDriverDisconnect(hWndC);
>     FreeLibrary(AVICapDllHandle);
>     Close();
>   }
>   TimerRefresh->Enabled = true;
>
>
Technical Details
Message-ID: <3fcd4633$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fc6476a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10d0fc,f3d9d5312ab89140
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2003-12-02 18:40:13 PST
Reply-To: "Edward" <registrados@via-rs.net>
From: "Edward" <registrados@via-rs.net>
Newsgroups: borland.public.cppbuilder.multimedia
References: <3fc6476a$1@newsgroups.borland.com>
Subject: OTHER WAY
Date: Wed, 3 Dec 2003 00:10:32 -0200
Lines: 155
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: 200.198.155.216
Message-ID: <3fcd4633$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070417459 200.198.155.216 (2 Dec 2003 18:10:59 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail