On 11 Apr 2005 17:48:58 +0200, you wrote: > Rein Klazes <[EMAIL PROTECTED]> writes: > > > I tried to do this, you need to clip to the visible region as well. I > > could not get it 100% full proof because of races between the clip > > calculations and the actual positions on the screen. > > > > So I get the pixels now from the root window (clipped to the screen) and > > everything is rock solid. The code is simpler too. > > That's ugly, and it will fail miserably if the drawable is a bitmap, > you really have to use the specified drawable. Look at how the BitBlt > code does it to determine the proper limits.
Hmm, I was looking at BitBlt for ideas. This was the straight forward implementation but then discarded: static void X11DRV_DIB_SetImageBits_GetSubImage( const X11DRV_DIB_IMAGEBITS_DESCR *descr, XImage *bmpImage) { /* compressed bitmaps may contain gaps in them. So make a copy * of the existing pixels first */ RECT bmprc = { descr->xDest, descr->yDest, descr->xDest + descr->width , descr->yDest + descr->height}; RECT rc; GetRgnBox( descr->physDev->region, &rc ); /* convert from dc to drawable origin */ OffsetRect( &rc, descr->physDev->org.x, descr->physDev->org.y); /* clip visible rect with bitmap */ if( IntersectRect( &rc, &rc, &bmprc)) XGetSubImage( gdi_display, descr->drawable, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, AllPlanes, ZPixmap, bmpImage, descr->xSrc + rc.left - bmprc.left, descr->ySrc + rc.top - bmprc.top); } As soon as I move the window to which I am calling SetDIBitsToDevice partly outside of the screen, the drawable lies partly outside the screen rectangle and XGetSubImage fails -> crash. Clipping to the screen rectangle helps somewhat for very slow moves, but with faster moves I still get those failures. What am I doing wrong here? Rein.