home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / x / 19185 < prev    next >
Encoding:
Text File  |  1992-11-16  |  2.3 KB  |  57 lines

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