Screen shots with OPenGL

Tech-Archive recommends: Fix windows errors by optimizing your registry



I am trying to get a screenshot of a window with usage glReadPixels API's
exposed from OPenGLafter getting the current context. But if I move another
application window above my application window, the screen shot which i get
gets blurred and I get a screen shot which gets overlapped. My code is as
below
RECT r;
GetClientRect(g_windowRef,&r);
CRect rect(r);

CSize size(rect.Width(),rect.Height());
const int bytesPerPixel = 3;
int bytesPerRow = (bytesPerPixel * rect.Width() + 3) & ~3;
int NbBytes = bytesPerRow * rect.Height();

BITMAPINFO bmi;
BITMAPINFOHEADER header;
bmi.bmiHeader.biWidth = size.cx;
bmi.bmiHeader.biHeight = size.cy;
bmi.bmiHeader.biSizeImage = NbBytes;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = bytesPerPixel * 8; // RGB
bmi.bmiHeader.biCompression =0;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;

bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
HANDLE handle = (HANDLE)::GlobalAlloc (GHND,sizeof(BITMAPINFOHEADER) +
NbBytes);
char *pData = NULL;
if(handle != NULL)
{
// Lock handle
pData = (char *) ::GlobalLock((HGLOBAL)handle);
// Copy header and data
memcpy(pData, &bmi.bmiHeader, sizeof(BITMAPINFOHEADER));

// Copy from OpenGL
glReadPixels(0, size.cx,size.cy,0,

GL_BGR_EXT,GL_UNSIGNED_BYTE,
pData + sizeof(BITMAPINFOHEADER));
// Unlock::GlobalUnlock((HGLOBAL)handle);
// Push DIB in
clipboard
OpenClipboard(g_windowRef);

EmptyClipboard();

SetClipboardData(CF_DIB,handle);
CloseClipboard();
}



.



Relevant Pages

  • Re: web page screen capture utility?
    ... capture of a web page? ... You can use 'import' to grab a shot of a particular window given its ... then do a firefox -remote URL command to load the page i want ... Unless the screenshot is critical, ...
    (comp.os.linux.misc)
  • Re: Will Apple EVER fix Window resizing?????
    ... It is not a "fix", ... that is *not* a screenshot of System 7. ... and the middle button has been "Zoom" since at least then. ... your window to take up the entire screen, ...
    (comp.sys.mac.advocacy)
  • Re: Firefox 3 RC1
    ... It doesn't look exactly like a Mac app. ... I just remember it being a royal pain to spot the frontmost window ... See the resize widget? ... I see no link to a screenshot. ...
    (uk.comp.sys.mac)
  • Re: Is there a screencapture utility?
    ... window capture. ... >>|After you've taken the screenshot, ...
    (Debian-User)
  • Re: select from another window using ms paint
    ... it was just like taking a screenshot over a limited ... More likely they were using some third party screen capture program OR you were watching after they had pasted the captured screen image into Paint and they were in the process of cropping the image. ... Note that the screen capture will be limited to the active window if you hold the ALT key down while you press the "Print Screen" key. ...
    (microsoft.public.windowsxp.basics)