[comp.windows.open-look] How much is "enough" image data

frank@odetics.com (Frank Merrow) (05/11/91)

Hi,

I am writing my first X program, using Xview.  (X is easily the most
complicated system I have ever tried to learn!  Fun though!)  I have
the "canvas" working and can use XDrawPoint() to change it and even
have the Rectangles figured out for "redraw" events.  However,
XDrawPoint() has its limitation.  (How do I select color and how do
I "undraw" a point?)

I gather that the peferred method is to create an XImage and do
XPutPixel() calls.  It even looks like XPutImage() is all setup
to "fix" the Rectangles on redraw events.  The problem is that
XCreateImage() does not allocate the "data"; I am required to
provide the pointer.  I have an example where the author uses
malloc(width*height), but I can not find anything that indicates
this is ever (much less always) correct.  It seems the size
should depend on the depth too.  Does anyone know the "correct"
way for allocating this array?  I get malloc() will do the job
but what is the "official" size of the array?

Also, since I am new at this, is this approach "correct" and
"workable" or should I be doing it another way?  For my application
I need to control each pixel of the canvas individually.

Frank
frank@odetics.com or uunet!odetics!frank