[comp.windows.x] XGetImage on Sun XServer

twl@cadreri.UUCP (Todd W. Lainhart) (04/05/91)

I need some xpert help:

I'm running whatever version of the X Server bundled with OpenWindows 2.0,
running Sun OS 4.1.1 on Sparc.  I've got a pixmap 2016x1584 that I'm reading chunks
of, in 32x32 bit swatches, and ultimately converting that (with the
help of XGetPixel) to another bitmap format for printing.

Here's what the call looks like:

    bitmap_image = XGetImage( xdisplay,
                              my_pixmap,
                              x_offset,
                              y_offset,
                              width,
                              height,
                              AllPlanes,
                              ZPixmap );

As I said, width and height are both 32.  The problem is, once x_offset and
y_offset reach > 1280x1056, XGetImage continually returns NULL.  Clearly, the rectangle
offset into the pixmap does not exceed the bounds of the rectangle.  XGetGeometry
returns 2016x1584 for the width and height of the pixmap, even after XGetImage
returns NULL.  Note that this only seems to happen on the Sun XServer - other
Servers I've tried don't behave this way.

Granted, this is a pretty large pixmap, but it seems that I might have discovered a
bug here.  Does anyone have any knowledge or experience that might shed some light
on this problem?

Thanks.

    -- Todd

doug@genmri.UUCP (Doug Becker) (04/05/91)

    The problem is, once x_offset and
    y_offset reach > 1280x1056, XGetImage continually returns NULL.

It's only a hunch, but I'll bet this is a memory-related problem.  In
particular, perhaps one of the following is happening:

The server is unable to ALLOCATE_LOCAL a hunk of memory and returns
BadAlloc to _XReply, which returns status 0 (error) to XGetImage, which
returns NULL to you.  Interestingly, Alloc is not listed as one of the
possible errors for the GetImage request, although the GetImage request
seems capable of generating it (R4: mit/server/dix/dispatch.c, line 1952).

The server returns the image successfully, but Xlib is unable to Xcalloc an
XImage to return to you, so XCreateImage returns NULL to XGetImage, which
passes the NULL pointer on to you.

Try freeing up some memory to see if this is indeed the case.

-- 

Doug Becker
doug@nmri.ge.com
crdgw1!sane!doug