Image sizing a problem...

Jim MacConnell jmac at consensustech.com
Thu Nov 18 15:49:52 EST 2004


Jim,

I had to look at this for a while... And again the docs come to the
rescue.... And the fact that imageData needs to go into the same size image
as the "reshaped original" or the pixel count doesn't work... Which can lead
to all sorts of weird things. So... Make sure your sizes work out.

Then, instead of:
>   set the icon of button whatPosition to the short id of image whatPosition
Try:
>   set the icon of button whatPosition to whatPosition
If I'm right, this will work. It seems for the "set icon" command, Rev
assumes you are using an image. That way you can't inadvertently put text
into an icon?

This brings up another point. From the ubiquitous use of whatPosition, I
assume you are "passing" this into the handler. If the above works, you will
now have the same "name" applying to 1) a button, 2) an image, and 3) the
data to put into the icon of the button. Easy to get lost. I would guess you
could (at the expense of a little memory) make this a little clearer by
using different names?

Of course, at this point, maybe you dump the image whatPosition altogether

> set the showName of button whatPosition to false
>   set the style of button whatPosition to transparent
>   put 43 into theTargetSize
>   if there is not an image "tempImage" then create image "tempImage"
>   hide image "tempImage"
>   -- Load image into tempImage
>   put gGraphImg into image "tempImage"
>   -- Resize the temporary image
>   put theTargetSize/the formattedwidth of image "tempImage" into theRatio
>   set the width of image "tempImage" to theTargetSize
>   set the height of image "tempImage" to \
>       round(the formattedheight of image "tempImage" * theRatio)
>   if the height of image "tempImage" > 25 then set the height of image
> "tempImage" to 25
>  -- load the temp image into the icon
>   set the icon of button whatPosition to "tempImage"

Reason for the whatPosition image still being big.... Check to see if you
have multiple instances of image whatPosition. When I was checking this out
I ended up with 4 image "TestImage" which really screwed me up when I was
checking sizes. Each time I created one, I forgot to delete the old.

Jim




More information about the use-livecode mailing list