[comp.windows.news] width and height of canvases?

jcm@nori.Philips.Com (John Martin) (02/15/89)

I would like to find out the width and height of an SRF image that has been
read with readcanvas. Does anyone know how to do this?

For example, after the line:

	(/c3/jcm/images/car.im8) readcanvas

the new canvas is on the stack, and I would like to know what aspect ratio
to use in displaying it before I pass it to imagecanvas.

There are some properties of canvases that can be inquired about, but
in keeping with the device indepedence of NeWS, width and height don't
seem to be accessible. The information is certainly there, because:

	(/c3/jcm/images/car.im8) readcanvas 
	pstack 

will show the canvas name, including its width and height in
parentheses.

Thanks very much.

	John Martin
	Philips Labs
	jcm@philabs.philips.com

jcm@nori.Philips.Com (John Martin) (02/15/89)

In article <44718@philabs.Philips.Com> I write:
>I would like to find out the width and height of an SRF image that has been
>read with readcanvas. Does anyone know how to do this?
>For example, after the line:
>
>	(/c3/jcm/images/car.im8) readcanvas
>
>the new canvas is on the stack, and I would like to know what aspect ratio
>to use in displaying it before I pass it to imagecanvas.

In case anyone is interested, one possible way is:

	(/c3/jcm/images/car.im8) readcanvas dup
	setcanvas
	initclip clippath pathbbox
	/height exch def
	/width exch def
	pop pop
	imagecanvas

Thanks to Laura Appleton, who (ironically) sits 50 feet away.

	John Martin
	Philips Labs
	jcm@philabs.philips.com

	

msc@ramoth.SGI.COM (Mark Callow) (02/21/89)

Here's how to I do it


/Cover BeautyDir (back.im8) append readcanvas def
% Calculate the aspect ratio of the image
/Ratio Cover setcanvas clippath pathbbox div 3 1 roll pop pop def

--
	-Mark