PDA

View Full Version : getting real width and height of an image


mallesh
01-16-2004, 06:02 AM
Hi Antun,

How do i get the original shape (real width and height) of an image in the view that get the image through setSource method?

Here,

<canvas>
<view x="50" y="10" name="foo" resource="pelican.jpg" stretches="both" />

<button y="200" label="+" width="70" height="20"
onclick="foo.setWidth( foo.width +10 );
foo.setHeight( foo.height + 10); foo.setX(foo.x-5); foo.sety(foo.y-5);"/>
<button x="100" y="200" label="-" width="70" height="20"
onclick="foo.setWidth( foo.width -10 ) ;
foo.setHeight( foo.height - 10);foo.setX(foo.x+5); foo.sety(foo.y+5); "/>
</canvas>

In the above code, i am able to get the original width and height of an image (without giving width and height for that view)

but in below code i can't able to get the original width and height of an image in the view.
<canvas debug="true">
<dataset name="ddset" src="image.xml" autorequest="true" type="http" />

<view x="50" y="10" name="foo" stretches="both" datapath="ddset:/ClipArtImg/ClipArt/text()">
<method name="applyData" args="d">
setSource( "http://localhost:8080/lps-1.0.3/lz-utils/laszloexamples/" +d);
Debug.write("jfsjkafq:"+d);
</method>
</view>

<button y="200" label="+" width="70" height="20"
onclick="foo.setWidth( foo.width +10 );
foo.setHeight( foo.height + 10); foo.setX(foo.x-5); foo.sety(foo.y-5);"/>

<button x="100" y="200" label="-" width="70" height="20"
onclick="foo.setWidth( foo.width -10 ) ;
foo.setHeight( foo.height - 10);foo.setX(foo.x+5); foo.sety(foo.y+5); "/>

</canvas>
this is (image.xml)the simple xml file for dataset

<ClipArtImg>
<ClipArt>pelican.jpg</ClipArt>
</ClipArtImg>




So i do i get the original width and height in image in the second code?(in which, the view use setSource for getting resource)



Thanks
Mallesh

antun
01-16-2004, 09:52 AM
Use the resourceheight and resourcewidth attributes of the view:

http://www.laszlosystems.com/developers/learn/documentation/lzxref/view.php#attr-resourceheight

-Antun