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