home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / fj / maillis / xwindow / 17522 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.5 KB

  1. Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
  2. From: cjmchale@dsg.cs.tcd.ie (Ciaran McHale)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Re: Resizing a pixmap
  5. Message-ID: <1992Nov17.012723.1631@sm.sony.co.jp>
  6. Date: 17 Nov 92 01:27:23 GMT
  7. Sender: daemon@sm.sony.co.jp (The devil himself)
  8. Distribution: fj
  9. Organization: DSG, Dept. of Computer Science, Trinity College Dublin
  10. Lines: 52
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: 16 Nov 92 11:57:33 GMT
  14. Message-Id: <1992Nov16.115733.17583@dsg.cs.tcd.ie>
  15. Newsgroups: comp.windows.x
  16. References: <26475@optima.cs.arizona.edu>, <MELBY.92Nov16005529@dove.yk.Fujitsu.CO.JP>
  17. Sender: xpert-request@expo.lcs.mit.edu
  18.  
  19. In <MELBY.92Nov16005529@dove.yk.Fujitsu.CO.JP>
  20. melby@dove.yk.Fujitsu.CO.JP (John B. Melby) writes:
  21. >>I'm looking for a quick way to resize a pixmap. Any suggestion will be
  22. >>appreciated.
  23. >
  24. >Unfortunately the server does not handle this.  In the general case,
  25. >a pixmap can be resized as follows:
  26. >[copy to XImage; create second, different-sized XImage; copy from the
  27. >first to the second using a scaling algorithm; copy the result back into
  28. >a new pixmap]
  29.  
  30. If you just want a different size pixmap, but do not want to scale its
  31. existing contents to fit then I suggest you use the following:
  32.  
  33.     /*
  34.     ** On input: p1 = the pixmap to be "resized"
  35.     */
  36.     p2 = XCreatePixmap(...)        /* of the required size */
  37.     XFillRectangle(dpy, p2, ...);    /* fill with a colour to "clear" it */
  38.     XCopyArea(dpy, p1, p2, ...);    /* copy from old pixmap to new */
  39.     XFreePixmap(dpy, p1);        /* delete the old pixmap */
  40.     p1 = p2;
  41.     /*
  42.     ** On output: p1 has been "resized"
  43.     */
  44.  
  45. A potential problem is that this algorithm requires that there will be
  46. two pixmaps in existance for a short amount of time. If they are both
  47. large, or the server has a limitation on how much memory can be
  48. allocated for pixmaps, then the server might not be able to allocate
  49. the second pixmap.
  50.  
  51. The algorithm using XImages suggested by the previous poster (John B.
  52. Melby) requires even more use of memory, but this memory is used in the
  53. client rather than the X server. The client may well have more
  54. available memory than the X server so this is not so much of a problem.
  55. It does have the disadvantage of being slower since transmitting all
  56. the data from the pixmap (in the X server) to the XImage (in the
  57. client), and back again, will probably take a long time.
  58.  
  59.  
  60. Ciaran.
  61. -- 
  62. ---- Ciaran McHale (cjmchale@dsg.cs.tcd.ie)
  63. \bi/ Department of Computer Science, Trinity College, Dublin 2, Ireland.
  64.  \/  Telephone: +353-1-7021539 FAX: +353-1-6772204
  65.