CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Screen Snapshot

  1. #1
    Join Date
    Sep 2003
    Posts
    815

    Screen Snapshot

    Hello,

    How do I get the screen snapshot, is there an API for that?

    Thanks
    Avi123

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

  3. #3
    Join Date
    Sep 2003
    Posts
    815

    Re: Screen Snapshot

    and how do I save it to a (bmp?) file & open this bmp (programmaticly) by some other application?

    Thanks
    Avi123

  4. #4
    Join Date
    Sep 2003
    Posts
    815

    Re: Screen Snapshot

    Quote Originally Posted by Ejaz
    I can't download the source! (Article not found!)

    Thanks
    Avi123

  5. #5
    Join Date
    Apr 2005
    Location
    Mumbai,India
    Posts
    185

    Re: Screen Snapshot

    Simulate pressing printscreen key, it will copy screen snapshot to clipboard, latter u can take it from clipboard. For simulating key, use keybd_event() or SendInput() function. and use following key
    VK_SNAPSHOT (0x002C -virtual code of print screen)

    Life is what u make it and u can make it more simple..........and woderful.
    Rate is what give and it give me pleasure.


  6. #6
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Screen Snapshot

    Thats wierd. Anyway, try this one.

    Barry's Screen Capture from CodeProject.

  7. #7
    Join Date
    May 2005
    Posts
    4,954

    Re: Screen Snapshot

    and how do I save it to a (bmp?) file & open this bmp (programmaticly) by some other application?
    use this code:
    Code:
    void WriteBmp(char* name,int W,int H,int* data)
    {
    BITMAPINFO Bmi;
    	memset(&Bmi,0,sizeof(BITMAPINFO));
    	Bmi.bmiHeader.biSize			= sizeof(BITMAPINFOHEADER);
    	Bmi.bmiHeader.biWidth			=  W;
    	Bmi.bmiHeader.biHeight			= H;
    	Bmi.bmiHeader.biPlanes			= 1;
    	Bmi.bmiHeader.biBitCount		= 32; 
    	Bmi.bmiHeader.biCompression	= BI_RGB;
    	Bmi.bmiHeader.biSizeImage		= W*H*4; 
    
    	FILE* image = fopen (name,"wb");
    	if(image==0)
    		return;
    	int h = abs(Bmi.bmiHeader.biHeight);
    	int w = abs(Bmi.bmiHeader.biWidth);
    	Bmi.bmiHeader.biHeight=h;
    	Bmi.bmiHeader.biWidth=w;
    	int sz = Bmi.bmiHeader.biSizeImage;
    
    	BITMAPFILEHEADER bfh;
    	bfh.bfType=('M'<<8)+'B'; 
       bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); 
       bfh.bfSize=sz+bfh.bfOffBits; 
       bfh.bfReserved1=0; 
       bfh.bfReserved2=0; 
    	fwrite(&bfh,sizeof(bfh),1,image);
    	fwrite(&Bmi.bmiHeader,sizeof(BITMAPINFOHEADER),1,image);
    	fwrite(data,sz,1,image);
    	fclose(image);
    }
    if i helped dont forget to rate :-)
    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured