Mark Swindell wrote:
Yes, using smaller images definitely reduces the display time... a
batch of smaller gif/jpg line drawings only takes 1.5 seconds to
display, but the idea is that the user can choose any image folder
off their HD to create a custom, high-interest game (family members,
friends, animals being studied (marsupials at present, mate).

I had a similar issue in a client project, only we wanted to save disk space instead of load time. We ended up copying the user's image to a folder in Application Data (you could use the temp folder instead) and resizing it for display. The resizing and disk write is very fast and it reduces multi-meg camera images to a few hundred K. If you aren't going to re-use the images then this probably won't work -- you may as well use the time just to show the image -- but if you need to load them again later, resizing helps.

Here's what I'm using:

on reduceImgSize pFileName,pDestPath,pWidth,pHeight
  -- reduce disk footprint; scale & compress.
-- first param is orig img file; second is destination file path, followed by target dimensions
  if pWidth = "" then put 640 into pWidth
  if pHeight = "" then put 480 into pHeight
  set the cursor to watch
  create img "temp"
  set the width of img "temp" to pWidth
  set the height of img "temp" to pHeight
  set the lockloc of img "temp" to true
  set the filename of img "temp" to pFileName
  if the formattedWidth of img "temp" > pWidth then
    get scaleToFit(the name of img "temp",the rect of img "temp")
    set the imageData of img "temp" to the imageData of img "temp"
    set the JPEGQuality to 80
    export img "temp" to file pDestPath as jpeg
  else -- img is small enough
    put URL ("binfile:"&pFileName) into URL ("binfile:"&pDestPath)
  end if
  delete img "temp"
end reduceImgSize

function scaleToFit pImg,pRect
  -- scale an image to fit a rectangle
  -- params: the image long name, the target rect
  put the formattedHeight of pImg into tFHt
  put the formattedWidth of pImg into tFWd
  put item 3 of pRect - item 1 of pRect into tTargetWd
  put item 4 of pRect - item 2 of pRect into tTargetHt
  put false into tWasScaled -- init
  if "image" is in pImg then set the rect of pImg to pRect -- to init
  put the loc of pImg into tLoc
  set the width of pImg to tFWd
  set the height of pImg to tFHt
  if tTargetHt < tFHt or tTargetWd < tFWd then
    put min(tTargetHt/tFHt, tTargetWd/tFWd) into theRatio
    set the height of pImg to tFHt*theRatio
    set the width of pImg to tFWd*theRatio
    put true into tWasScaled
  end if
  set the loc of pImg to tLoc
  return tWasScaled
end scaleToFit

--
Jacqueline Landman Gay         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to