Image sizing a problem...

Jim Carwardine JimCarwardine at OwnYourFuture-net.com
Fri Nov 19 05:38:25 EST 2004


Jim... Thanks again for your help.  Here is the script that seems to work.
Setting the rect of image whatPosition seemed to do the trick.  I put back
the set icon statement to the short id of the image...

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 whatPosition then create image whatPosition
  if there is not an image "tempImage" then create image "tempImage"
  hide image whatPosition
  hide image "tempImage"
  
  put gGraphImg into image "tempImage"
  
  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
  set the rect of image whatPosition to the rect of image "tempImage"
  put the imageData of image "tempImage" into tempResizedImage
  set the imageData of image whatPosition to tempResizedImage

  set the icon of button whatPosition to the short id of image whatPosition
 


Jim

on 11/18/04 4:49 PM, Jim MacConnell wrote:

> 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
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

-- 

OYF is... Highly resourceful people working together.
<http://www.OwnYourFuture-net.com>

Own Your Future Consulting Services Limited,
1959 Upper Water Street, Suite 407, Halifax, Nova Scotia. B3J 3N2
Info Line: 902-823-2477, Phone: 902-823-2339. Fax: 902-823-2139





More information about the use-livecode mailing list