Click here to Skip to main content
15,568,718 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Code works when debugging and not when executing Pin
Spykraft30-Nov-07 11:41
Spykraft30-Nov-07 11:41 
AnswerRe: Code works when debugging and not when executing Pin
peterchen30-Nov-07 10:56
peterchen30-Nov-07 10:56 
GeneralRe: Code works when debugging and not when executing Pin
Spykraft30-Nov-07 11:44
Spykraft30-Nov-07 11:44 
GeneralRe: Code works when debugging and not when executing Pin
peterchen1-Dec-07 4:20
peterchen1-Dec-07 4:20 
AnswerRe: Code works when debugging and not when executing Pin
ied30-Nov-07 13:27
ied30-Nov-07 13:27 
Questionwhat is the shadow in clinet area Pin
_Pinux_30-Nov-07 6:00
_Pinux_30-Nov-07 6:00 
AnswerRe: what is the shadow in clinet area Pin
Iain Clarke, Warrior Programmer30-Nov-07 7:27
Iain Clarke, Warrior Programmer30-Nov-07 7:27 
QuestionBitBlt mystery problem Pin
csmanul30-Nov-07 5:40
csmanul30-Nov-07 5:40 
hello , i've tryed to capture snapshots on yahoo webcam with bitblt to make a yahoo webcam recorder, i managed to do it but with some problems. on my webcam it works perfectly the image captured is clear but if i try to snapshot another webcam window(some work some don't) the image is scrambled. i will post the entire source code it's not too long and a sample snapshot to see the problem.

http://rapidshare.com/files/73346892/frame_2.bmp.html



<br />
   HWND frame,mainwin,last=NULL;<br />
<br />
<br />
bool writebmpfile(int bitmap_dx,int bitmap_dy,int bytes, BYTE *memory,BITMAPFILEHEADER fileHeader,BITMAPINFOHEADER infoHeader,int frame);<br />
<br />
<br />
typedef struct cadre<br />
{<br />
    char cadru[200];<br />
}cadre;<br />
<br />
<br />
cadre cadre[10000];<br />
<br />
<br />
<br />
BOOL CALLBACK findchildweb(HWND hwnd,LPARAM lParam)<br />
{<br />
    char clasa[100]={0};<br />
    char text[150]={0};<br />
<br />
<br />
    GetClassName(hwnd,clasa,100);<br />
<br />
    if(!strcmp(clasa,"ATL:0B39D378")|| !strcmp(clasa,"#32770"))<br />
    {    <br />
        frame=hwnd;<br />
<br />
    <br />
    }<br />
<br />
    GetWindowText(hwnd,text,150);<br />
<br />
    if(strstr(text,"Last")!=NULL || strstr(text,"Broadcast")!=NULL)<br />
    {<br />
        last=hwnd;<br />
<br />
    }<br />
<br />
<br />
<br />
    <br />
    if(last!=NULL && frame!=NULL)<br />
        return false;<br />
    else<br />
        return true;<br />
<br />
}<br />
<br />
<br />
<br />
//----------------------------------------------------------<br />
BOOL CALLBACK findwebwnd(HWND hwnd,LPARAM lParam)<br />
{<br />
    char clasa[100]={0};<br />
<br />
    GetClassName(hwnd,clasa,100);<br />
<br />
    if(!strcmp(clasa,"WebcamClass"))<br />
    {<br />
        mainwin=hwnd;<br />
        EnumChildWindows(hwnd,findchildweb,0);<br />
        return false;<br />
<br />
    }<br />
<br />
<br />
<br />
<br />
<br />
    return true;<br />
}<br />
<br />
<br />
<br />
//--------------------------------------------------------<br />
<br />
bool findandcapture()<br />
{<br />
     frame=NULL;<br />
     HDC devcnt=NULL,devc=NULL,cmpdc=NULL;<br />
     RECT dim={0};<br />
     HBITMAP bmp=NULL;<br />
     BYTE *memory=0;<br />
<br />
    BITMAPFILEHEADER fileHeader;<br />
    BITMAPINFOHEADER infoHeader;<br />
    BITMAPINFO info;<br />
    int numframe=-1;<br />
<br />
    char cur[150]={0},prev[150]={0};<br />
    <br />
<br />
<br />
    <br />
<br />
<br />
    EnumWindows(findwebwnd,0);<br />
<br />
<br />
    <br />
    <br />
    if(frame!=NULL)<br />
    devcnt=GetWindowDC(frame);<br />
    else<br />
        return false;<br />
<br />
    GetWindowRect(frame,&dim);<br />
<br />
    int bitmap_dx = dim.right - dim.left;<br />
    int bitmap_dy = dim.bottom - dim.top;<br />
<br />
//------------headerul bitmap----------------------<br />
    fileHeader.bfType      = 0x4d42;<br />
         fileHeader.bfSize      = 0;<br />
         fileHeader.bfReserved1 = 0;<br />
         fileHeader.bfReserved2 = 0;<br />
         fileHeader.bfOffBits   = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);<br />
<br />
         infoHeader.biSize          = sizeof(infoHeader);<br />
         infoHeader.biWidth         = bitmap_dx;<br />
         infoHeader.biHeight        = bitmap_dy;<br />
         infoHeader.biPlanes        = 1;<br />
         infoHeader.biBitCount      = 24;<br />
         infoHeader.biCompression   = BI_RGB;<br />
         infoHeader.biSizeImage     = 0;<br />
         infoHeader.biXPelsPerMeter = 0;<br />
         infoHeader.biYPelsPerMeter = 0;<br />
         infoHeader.biClrUsed       = 0;<br />
         infoHeader.biClrImportant  = 0;<br />
         info.bmiHeader = infoHeader;<br />
<br />
<br />
//------------headerul bitmap----------------------<br />
<br />
             cmpdc=CreateCompatibleDC(devcnt);<br />
<br />
    bmp=CreateDIBSection(devcnt, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0);<br />
    DWORD eror=GetLastError();<br />
    SelectObject(cmpdc,bmp);<br />
<br />
<br />
<br />
    while(1)<br />
    {<br />
        <br />
<br />
        if(strcmp(cur,prev) || strstr(prev,"Broad")!=NULL)<br />
        {<br />
                numframe++;<br />
<br />
        GetWindowText(last,cur,150);<br />
<br />
            BitBlt(cmpdc, 0, 0, bitmap_dx, bitmap_dy, devcnt, 0, 0, SRCCOPY);<br />
<br />
             int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy;<br />
<br />
<br />
<br />
              writebmpfile(bitmap_dx,bitmap_dy, bytes, memory,fileHeader,infoHeader,numframe);<br />
<br />
<br />
             DeleteObject(bmp);<br />
<br />
              if(UpdateWindow(mainwin)==false)<br />
                  break;<br />
<br />
              if(strstr(prev,"Broad")!=NULL)<br />
                  Sleep(500);<br />
<br />
        }<br />
        else<br />
            Sleep(1);<br />
<br />
<br />
        GetWindowText(last,prev,150);<br />
<br />
<br />
<br />
<br />
    Sleep(1);<br />
    }<br />
<br />
<br />
<br />
<br />
    DeleteDC(cmpdc);<br />
    ReleaseDC(frame, devcnt);<br />
<br />
<br />
<br />
<br />
<br />
    return true;<br />
}<br />
<br />
//---------------------------------------------------------------------------------------------<br />
<br />
bool writebmpfile(int bitmap_dx,int bitmap_dy,int bytes, BYTE *memory,BITMAPFILEHEADER fileHeader,BITMAPINFOHEADER infoHeader,int frame)<br />
{<br />
<br />
<br />
<br />
<br />
    FILE *fisier;<br />
    <br />
    <br />
    sprintf(cadre[frame].cadru,"%s_%d.%s","frame",frame,"bmp");<br />
<br />
        <br />
<br />
         fisier=fopen(cadre[frame].cadru,"w+");<br />
<br />
<br />
<br />
         fwrite((char*)&fileHeader,1,sizeof(fileHeader),fisier);<br />
<br />
         fwrite((char*)&infoHeader,1,sizeof(infoHeader),fisier);<br />
<br />
         fwrite(memory,1,bytes,fisier);<br />
<br />
    <br />
<br />
         fclose (fisier);<br />
<br />
<br />
<br />
<br />
    return true;<br />
}<br />
<br />
<br />
<br />

QuestionRe: BitBlt mystery problem Pin
Mark Salsbery30-Nov-07 10:46
Mark Salsbery30-Nov-07 10:46 
AnswerRe: BitBlt mystery problem Pin
csmanul30-Nov-07 12:58
csmanul30-Nov-07 12:58 
GeneralRe: BitBlt mystery problem Pin
Mark Salsbery30-Nov-07 13:12
Mark Salsbery30-Nov-07 13:12 
GeneralRe: BitBlt mystery problem Pin
csmanul30-Nov-07 13:58
csmanul30-Nov-07 13:58 
GeneralRe: BitBlt mystery problem Pin
Mark Salsbery30-Nov-07 14:18
Mark Salsbery30-Nov-07 14:18 
GeneralRe: BitBlt mystery problem Pin
Mark Salsbery30-Nov-07 14:28
Mark Salsbery30-Nov-07 14:28 
GeneralRe: BitBlt mystery problem Pin
csmanul30-Nov-07 14:38
csmanul30-Nov-07 14:38 
GeneralRe: BitBlt mystery problem Pin
Mark Salsbery30-Nov-07 14:46
Mark Salsbery30-Nov-07 14:46 
GeneralRe: BitBlt mystery problem Pin
csmanul30-Nov-07 14:55
csmanul30-Nov-07 14:55 
QuestionDial up connection on Vista Pin
Sonani Prakash30-Nov-07 5:31
Sonani Prakash30-Nov-07 5:31 
Questionruntime library option Pin
George_George30-Nov-07 4:47
George_George30-Nov-07 4:47 
AnswerRe: runtime library option Pin
CPallini30-Nov-07 4:56
mveCPallini30-Nov-07 4:56 
GeneralRe: runtime library option Pin
Matthew Faithfull30-Nov-07 5:23
Matthew Faithfull30-Nov-07 5:23 
GeneralRe: runtime library option Pin
CPallini30-Nov-07 5:27
mveCPallini30-Nov-07 5:27 
QuestionSourceSafe problem Pin
followait30-Nov-07 3:39
followait30-Nov-07 3:39 
QuestionRe: SourceSafe problem Pin
David Crow30-Nov-07 4:07
David Crow30-Nov-07 4:07 
AnswerRe: SourceSafe problem Pin
followait30-Nov-07 4:20
followait30-Nov-07 4:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.