--- reset_image.H.orig Tue Jul 16 10:59:50 1996 +++ reset_image.H Tue Apr 7 15:34:33 1998 @@ -16,15 +16,24 @@ // to access data beyond the allocated image, that might lead to a segmentation // violation. Therefore, it might be good to allocated some additional // rows of data for the image. - offset_bytes=xwidth*offset_rows*sizeof(DATA_TYPE); - xdata=new DATA_TYPE[xwidth*(xheight+2*offset_rows)]; + + extern int scanline_pad; + + int byte_pad = scanline_pad / 8; + + offset_bytes=xwidth*offset_rows*DATA_BYTES; + // xdata=new DATA_TYPE[xwidth*(xheight+2*offset_rows)]; + + xdata=(DATA_TYPE*)new char[DATA_BYTES*xwidth*(xheight+2*offset_rows)]; { DATA_TYPE *xdata_run=xdata; unsigned long blk_pixel=BlackPixel(dpy,scr); for (int i=xwidth*(xheight+2*offset_rows);i>0;i--) { - *xdata_run++=(DATA_TYPE)blk_pixel; + // *xdata_run++=(DATA_TYPE)blk_pixel; + *xdata_run=(DATA_TYPE)blk_pixel; // align fault + ((char *)xdata_run) += DATA_BYTES; } } - xdata+=(offset_bytes/sizeof(DATA_TYPE)); + xdata+=(offset_bytes/DATA_BYTES); if (!xdata) { fprintf(stderr,"not enough memory for XImage-data"); @@ -32,9 +41,11 @@ } // create the XImage + ximage = XCreateImage(dpy, DefaultVisual(dpy,scr), - DefaultDepth(dpy,scr), ZPixmap, 0, - (char*)xdata, xwidth, xheight, 8*DATA_PAD, xwidth*sizeof(DATA_TYPE)); + DefaultDepth(dpy,scr), ZPixmap, 0, + (char*)xdata, xwidth, xheight, scanline_pad, + ((xwidth*DATA_BYTES + byte_pad - 1)/byte_pad) * byte_pad); if (!ximage) { fprintf(stderr,"\n*** can't allocate ximage.\n" ); @@ -47,9 +58,23 @@ register const byte *org = Data(); register int j,i; - for (i=0; i