revImageScale

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
MikeinHawaii
Posts: 90
Joined: Mon Jan 18, 2010 10:53 am

revImageScale

Post by MikeinHawaii » Thu Oct 14, 2010 9:53 pm

During the 09 Developers Conference, Ben Beaumont mentioned a new function that would be available in *the next release* that would be called revImageScale that will automatically scale image files to the selected container size for you. (disk 5/12 Intoduction to revWeb Plugin & revlets. I have had no luck with locating it in the Live Code release. Perhaps under a different name. Anybody know??

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: revImageScale

Post by Mark » Wed Jan 19, 2011 10:57 pm

Hi MikeinHawaii,

Maybe Ben was making a joke?

Here's a function that takes the dimensions of an image object and returns a new width and height of the object that will make it fit inside a second object.

Code: Select all

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
theImgWidth and theImgHeight are the width and height of the image object. TheCdWidth and theCdHeight are the width and height of the destination object (or card or stack).

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply