home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!lsl!snail
- From: snail@lsl.co.uk
- Newsgroups: comp.windows.x
- Subject: Re: Why the program cannot work?
- Message-ID: <1992Dec15.123014.2838@lsl.co.uk>
- Date: 15 Dec 92 11:30:14 GMT
- References: <1992Dec14.112849.21727@sparc4.ncu.edu.tw>
- Organization: Laser-Scan Ltd., Cambridge
- Lines: 83
-
- In article <1992Dec14.112849.21727@sparc4.ncu.edu.tw>, u438813@imux120.ncu.edu.tw (Lin Wei-Ting) writes:
-
- Well, I'll have a stab at this. Some of the code below isn't needed, see
- comments in the code. Also this code appears to be moving bytes from left to
- right and vice versa.
-
- > void inverse(item, event)
- > Panel_item item;
- > Event *event;
- > {
- > t_window1_objects *ip = (t_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
- > unsigned long p1,p2;
- > int y;
- > int lx,rx;
- > int i,j;
- > unsigned int k;
-
- > width=xv_get(obj,CANVAS_WIDTH);
- > height=xv_get(obj,CANVAS_HEIGHT);
-
- /* The next two lines are not needed, since the XGetImage sets everything up */
- >DELETE ximage=XCreateImage(theDisplay,theVisual,theDepth,ZPixmap,
- >DELETE 0,0,width,height,8,0);
- >DELETE ximage->data=(char *)malloc(sizeof(char)*width*height);
-
- > ximage=XGetImage(theDisplay,xwin,0,0,width,height,AllPlanes,ZPixmap);
- > for(i=0;i<height;i++)
- > {
- > data1=(char *)(ximage->data)+i*width;
-
- ZPixmap lists the pixels in scan line order with ximage->bits_per_pixel bits
- used per pixel.
-
- Having never done anything with ZPixmap I can't be sure, but I doubt if the
- following is correct. For a definate result you could use the XGetPixel() and
- XPutPixel() routines here, but they would be slow. Heres the code any way
-
- use this (SLOW):-
- This is coded for demonstration, not practice. Easy to optimise anyway.
-
- > for(j=0;j < (width * 8) /2;j++) /* 8 bits/byte*/
- > {
-
- temp_pixel1 = XGetPixel(ximage, j, i);
- temp_pixel2 = XGetPixel(ximage, j + (width * 8) / 2,i);
- XPutPixel(ximage, j, i, temp_pixel2);
- XPutPixel(ximage, j + (width * 8) / 2, i, temp_pixel1);
-
- in place of this (which I'm not sure about):-
-
- > for(j=0;j<width/2;j++)
- > {
- > k=*(data1+j);
- > *(data1+j)=*(data1+width-1-j);
- > *(data1+width-1-j)=k;
-
- > }
- > }
- > XPutImage(theDisplay,xwin,theGC,ximage,0,0,0,0,width,height);
-
- /* I doubt if this next line is needed */
- > XFlush(theDisplay);
-
- /* Next line not needed, never allocated anyway (I think it refered to
- ximage->data, which was never allocated by the user anyway - I deleted that
- line */
-
- >DELETE free(data);
-
- > XDestroyImage(ximage);
-
- /* I doubt if this next line is needed*/
- > XFlush(theDisplay);
- > }
-
- Thats my stab at it, if someone can shed some light on the ZPixmap stuff, great.
- --
- snail@lsl.co.uk
-
- muso/unix joke: "which debugger do you use?"
- "I use dbx..."
- "Oh really, we use Dolby C..."
- Motorola inside.
-