[comp.windows.x] Offscreen coordinate systems

brian@natinst.com (Brian H. Powell) (04/03/91)

     Our application has a single window, and it has several objects which
draw at various locations on this window.  (These objects are not themselves
windows.)  These objects know their bounds, and draw in the window's
coordinate system.
     We'd like to have these objects draw into an offscreen pixmap.  This is
not as simple as it sounds, evidently.  Pixmaps assume their origin is (0,0).
Therefore, we must either allocate a pixmap as big as our window, and leave
most of it unused, or we must inform these various objects that they're being
drawn offscreen, and need to munge on the coordinates.
     The former is easy to do, but seems like a waste.  E.g., if we need a
100x100 square in the lower right hand corner of a 1Kx1Kx32-bit window, we get
to allocate (on the server) 4 megabytes, of which we use 40K.  Yuck.
     The latter is also distasteful.  It'd probably be easiest to have a
coordinate translation that's done for every drawing command.  You can't
really change the objects' notion of where it is, because that'd screw up
picking.  (Or you could keep a separate rectangle:  one for drawing, one for
picking.  Again, yuck.)
     How do others deal with this situation?

Brian

ch@siet02.sietec.de (Chitty) (04/03/91)

Question
========	
     Our application has a single window, and it has several objects which
draw at various locations on this window.  (These objects are not themselves
windows.)  These objects know their bounds, and draw in the window's
coordinate system.
     We'd like to have these objects draw into an offscreen pixmap.  This is
not as simple as it sounds, evidently.  Pixmaps assume their origin is (0,0).
Therefore, we must either allocate a pixmap as big as our window, and leave
most of it unused, or we must inform these various objects that they're being
drawn offscreen, and need to munge on the coordinates.
     The former is easy to do, but seems like a waste.  E.g., if we need a
100x100 square in the lower right hand corner of a 1Kx1Kx32-bit window, we get
to allocate (on the server) 4 megabytes, of which we use 40K.  Yuck.
     The latter is also distasteful.  It'd probably be easiest to have a
coordinate translation that's done for every drawing command.  You can't
really change the objects' notion of where it is, because that'd screw up
picking.  (Or you could keep a separate rectangle:  one for drawing, one for
picking.  Again, yuck.)
     How do others deal with this situation?

Brian
	
Attempt
=======

Hi There,
          My personal view will be to have an array of objects with
small pixamps and should be drawn on the drawing area when
required ( using XCopyPlane )
for e.g.
        struct PixStru
        {
            int XOffset, XWidth ;
            int Width, Height ;
            Pixmap pixmap ;
        } PixStru_t

        /* So your prog could go */
        struct PixStru_t Areas[50] ;

        for ( i = 0 ; i < TotalAreas ; ++i )
             XCopyPlane(Display, Areas[i].Pixmap, dst, gc, 0, 0, Areas[i].Width,
                        Areas[i].Height, Areas[i].XOffset, Areas[i].YOffset, 1);

Thus having several small compact pixmaps will save a lot of valuable memory

===================================================================
Name : Chittaranjan Keswani        Sietec, West Berlin
Address : ch@siet02.sietec.de      (Internet)
          ..!sietec1!siet02!ch@unido.uucp (UUCP)
===================================================================