home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / windows / x / 20238 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.5 KB

  1. Path: sparky!uunet!spool.mu.edu!hri.com!noc.near.net!gateway!miki!oj
  2. From: oj@miki.pictel.com (Oliver Jones)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Why the program cannot work?
  5. Message-ID: <1992Dec15.174502.2680@miki.pictel.com>
  6. Date: 15 Dec 92 17:45:02 GMT
  7. References: <1992Dec14.112849.21727@sparc4.ncu.edu.tw>
  8. Organization: PictureTel Corporation
  9. Lines: 39
  10.  
  11. In article <1992Dec14.112849.21727@sparc4.ncu.edu.tw> u438813@imux120.ncu.edu.tw writes:
  12.  
  13. >void
  14. >inverse(item, event)
  15.   ...
  16.  
  17. >    ximage=XCreateImage(theDisplay,theVisual,theDepth,ZPixmap,
  18. >                        0,0,width,height,8,0);
  19. >    ximage->data=(char *)malloc(sizeof(char)*width*height);
  20. >    ximage=XGetImage(theDisplay,xwin,0,0,width,height,AllPlanes,ZPixmap);
  21. >    for(i=0;i<height;i++) { ...
  22. >            *(data1+j)=*(data1+width-1-j);
  23. >            *(data1+width-1-j)=k;
  24. >            ...
  25.  
  26. >        }
  27. >    XPutImage(theDisplay,xwin,theGC,ximage,0,0,0,0,width,height);
  28. >    XFlush(theDisplay);
  29. >    free(data);
  30. >    XDestroyImage(ximage);
  31. >    XFlush(theDisplay);
  32.  
  33. >I want to fl1ip an image horizontally.But the program doesn't work.Why?
  34.  
  35.  
  36. (1) I don't see declarations for width, height, or data1.
  37.     Are they declared appropriately?
  38.  
  39. (2) Try using XGetSubImage instead of XGetImage....
  40.     Your call to XCreateImage set up an XImage which allows you
  41.     the freedom to manipulate the data directly the way you are.
  42.  
  43.     However, XGetImage overwrites the image you created with
  44.     one created in the server's favorite format.
  45.  
  46. (3) Try using XGetPixel and XPutPixel in place of *(data1+width...)
  47.     to retrieve and store pixel values.
  48.  
  49. (4) [nit] The last XFlush serves no purpose.
  50.