// This include is meant to be the body of the function ResetXX, // which is implemented exactly the same for different resolutions. For // compatibility reasons this is controlled by Defines instead of templates. // Therefor the following type definitions are set to the required values, // while compiling that function: // // #define DATA_TYPE unsigned char // #define DATA_PAD 1 DATA_TYPE *xdata; // create buffer for Image-Data // there is an optimization in the rotation-routine, which sometimes tries // 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. 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; // align fault char *my_xdata_run = (char *)xdata_run; my_xdata_run += DATA_BYTES; } } xdata+=(offset_bytes/DATA_BYTES); if (!xdata) { fprintf(stderr,"not enough memory for XImage-data"); exit(-1); } // create the XImage ximage = XCreateImage(dpy, DefaultVisual(dpy,scr), 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" ); exit(0); } // copy data from original image and inserting pixel values on the fly if (Width()==xwidth&&Height()==xheight) { register DATA_TYPE *copy = xdata; register const byte *org = Data(); register int j,i; extern int pixmap_depth; switch(pixmap_depth) { case 8: // power of two covered by basic data type case 16: case 32: for (i=0; i0;x--) { delta-=xwidth; if (delta<0) { delta+=Width(); *copy++ = (DATA_TYPE)gif_cols[*org]; } org++; } } else { register int x; register int delta = xwidth/2; for (x=xwidth;x>0;x--) { delta-=Width(); *copy++ = (DATA_TYPE)gif_cols[*org]; if (delta<0) { delta+=xwidth; org++; } } } } } ximage->data = (char*)xdata; // XPutImage(dpy,pixmap,p->gc_all,ximage,0,0,0,0,xwidth,xheight);