[comp.windows.x] Zooming

sks@cs.brown.edu (Sumeet Singh) (11/07/90)

I am writing an application that must allow a user to zoom the image displayed
in a window.  How does one implement such a feature using X windows? Any
ideas would be appreciated.  Thanks.

Sumeet

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (11/07/90)

You can't do this explicitly in X.

The VERY easiest method is as follows:

	Assume original image I1 with dimensions m x n
	Assume new image I2 with dimensions M x N

	Each pixel I2(x,y) = I1(x * m / M,y * n / N)

This is a good first try.  Better algorithms
	utilize smoothing for enlarging images
	and averaging for shrinking images.  These alogorithms,
	however, assume a sophisicated color scheme for 8
	bit machines.
--
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bmc.tmc.edu
					(713) 798-3776

cflatter@ZIA.AOC.NRAO.EDU (Chris Flatters) (11/08/90)

> I am writing an application that must allow a user to zoom the image >
> displayed in a window.  How does one implement such a feature using X
> windows? Any ideas would be appreciated.  Thanks.

The only way I know of is to build the zoomed image in the client, using
either simple pixel replication or some form of interpolation, and then
XPutImage the zoomed image to the window.  Actually, it may be better to
load the zoomed image into a pixmap and then display that in a window. 
Providing that you have enough memory on the server side, this would speed
up redraws and scrolling operations since you wouldn't have to transfer
the image date to the server every time.

If there are better methods around, I would like to hear of them too.

			Chris Flatters

gjw@ANDREAS.WR.USGS.GOV (Gregory J. Woodhouse) (11/08/90)

What sort of image are you zooming on?  For arbitrary data, I suppose some
interpolation scheme would be the best you can do, but if it's possible to
rebuild your image, that might be preferable.  In my case, I work with
seismic data (surprise!), so I dsimply rebuild the image as I zoom on it.
It is reasonably fast, considering that any kind of interpolation is also
going to be computation intensive.
-----------------------------------------------------------------------------
Gregory Woodhouse          |We know that the center of the earth
gjw@andreas.wr.usgs.gov    |is a fiery molten mass...but it's not
(415) 329-4694 (office)    |good to dwell on it.
(415) 325-7802 (home)      |
U.S. Geological Survey / 345 Middlefield Rd. MS 977 / Menlo Park, CA 94025
-----------------------------------------------------------------------------

asente@adobe.com (Paul Asente) (11/09/90)

In article <9011071852.AA01344@zia.aoc.nrao.edu> cflatter@ZIA.AOC.NRAO.EDU (Chris Flatters) writes:
>
>> I am writing an application that must allow a user to zoom the image >
>> displayed in a window.  How does one implement such a feature using X
>> windows? Any ideas would be appreciated.  Thanks.

>The only way I know of is to build the zoomed image in the client, using
>either simple pixel replication or some form of interpolation, and then
>XPutImage the zoomed image to the window. 

Display PostScript, present in DEC and IBM servers, will scale (and rotate)
images.  Pretty fast, too.

	-paul asente
		asente@adobe.com	...decwrl!adobe!asente

cflatter@ZIA.AOC.NRAO.EDU (Chris Flatters) (11/10/90)

>>The only way I know of is to build the zoomed image in the client, using
>>either simple pixel replication or some form of interpolation, and then
>>XPutImage the zoomed image to the window. 
>
> Display PostScript, present in DEC and IBM servers, will scale (and rotate)
> images.  Pretty fast, too.
>
>           -paul asente

Good plug -- but we can't count on Display PostScript or NeWS being
available.  I was hoping for a better X only solution (until the X
imaging extension finally arrives).

			Chris Flatters

PS. From the recent activity around here it looks as though there might
be interest in defining an official X PostScript extension that could
act as a common API to both Display PostScript and NeWS (and any other
display oriented PostScript that might be around) --- at least at the
PostScript in a window level.  I'm assuming that this isn't already
happening somewhere.

PPS. I'm not volunteering to do anything.