How do I import and set images based upon their width and height?

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Jan 28 05:15:33 EST 2009


Hi William,

I used this to adjust images to the card size:

function rescale theImgWidth,theImgHeight,theCdWidth,theCdHeight
   if theCdWidth/theImgWidth < theCdHeight/theImgHeight then
     put theCdWidth / theImgWidth into myRatio
   else
     put theCdHeight / theImgHeight into myRatio
   end if
   put theImgWidth * myRatio into myNewWidth
   put theImgHeight * myRatio into myNewHeight
   return myNewWidth,myNewHeight
end rescale

The parameters theImgWidth and theImgHeight are the formattedWidth and  
formattedHeight of your image object and theCdWidth and theCdHeight  
are the width and height of the destination area. The function returns  
the new width and height for your image object.

I didn't think it is that cold here. It is almost 20 degrees warmer  
than some time ago. Btw maybe you should have asked in the Dutch  
forum... ;-)

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz
Dutch forum: http://runrev.info/rrforum

We are always looking for new projects! Feel free to contact us to  
discuss your custom software project!

On 28 jan 2009, at 11:07, William de Smet wrote:

> Hi there,
> I am trying to import images and put them into their own  
> 'dummyimage'  based
> upon their width and height.
> The 'dummyimages' are called Photo and Photo2.
> It doesn't work!
> Can someone help me with this one?
>
> *on* mouseUp
>
>   *put* empty into img "Photo"
>
>  *put* empty into img "Photo2"
>
>  *answer* file "Choose a photo:"
>
>  *if* it = empty
>
>  *then* *exit* mouseUp
>
>  *put* url ("binfile:" & it) into tPhoto
>
>  *put* the width of the last image into tWidth
>
>  *put* the height of the last image into tHeight
>
>  *if* tWidth <= tHeight
>
>  *then* *put* tPhoto into img "Photo2"
>
>  *if* tWidth >= tHeight
>
>  *then* *put* tPhoto into img "Photo"
> *end* mouseUp
>
> Thanks!
>
> Greetings,
>
> William (from a very cold Holland)





More information about the use-livecode mailing list