home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!hri.com!noc.near.net!gateway!miki!oj
- From: oj@miki.pictel.com (Oliver Jones)
- Newsgroups: comp.windows.x
- Subject: Re: Why the program cannot work?
- Message-ID: <1992Dec15.174502.2680@miki.pictel.com>
- Date: 15 Dec 92 17:45:02 GMT
- References: <1992Dec14.112849.21727@sparc4.ncu.edu.tw>
- Organization: PictureTel Corporation
- Lines: 39
-
- In article <1992Dec14.112849.21727@sparc4.ncu.edu.tw> u438813@imux120.ncu.edu.tw writes:
-
- >void
- >inverse(item, event)
- ...
-
- > ximage=XCreateImage(theDisplay,theVisual,theDepth,ZPixmap,
- > 0,0,width,height,8,0);
- > 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+j)=*(data1+width-1-j);
- > *(data1+width-1-j)=k;
- > ...
-
- > }
- > XPutImage(theDisplay,xwin,theGC,ximage,0,0,0,0,width,height);
- > XFlush(theDisplay);
- > free(data);
- > XDestroyImage(ximage);
- > XFlush(theDisplay);
-
- >I want to fl1ip an image horizontally.But the program doesn't work.Why?
-
-
- (1) I don't see declarations for width, height, or data1.
- Are they declared appropriately?
-
- (2) Try using XGetSubImage instead of XGetImage....
- Your call to XCreateImage set up an XImage which allows you
- the freedom to manipulate the data directly the way you are.
-
- However, XGetImage overwrites the image you created with
- one created in the server's favorite format.
-
- (3) Try using XGetPixel and XPutPixel in place of *(data1+width...)
- to retrieve and store pixel values.
-
- (4) [nit] The last XFlush serves no purpose.
-