Hi guys,
I'm developing my first application in LiveCode (Windows platform). I have an Image Object on the current card, and a button to view full size of image. If user click the button, a new card will be opened. I want to put the image (with original size) into the new card. But if size of image is larger than size of new card, I don't know how to display a scroll bar?
In case LiveCode can't display an image in large size, could I use LiveCode call another existing program to open the image (for example Windows Picture and Fax Viewer in Windows)?
Thanks so much!
Cheers,
Linh
How to open large size image
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: How to open large size image
Hi Linh,
stacks/cards can not have scrollbar in Livecode, but here is the trick:
1. Group your image, yes you can group even a single object!
2. Set the rect of the group to the rect of the card/stack
3. Enable the horzontal and vertical scrollbars for the group
Et voila, a scrollable image
Check the attached stack, one (not too) big image of a christmastree which is grouped.
And check the script of the card to see the "resizestack" script"
Best
Klaus
stacks/cards can not have scrollbar in Livecode, but here is the trick:
1. Group your image, yes you can group even a single object!
2. Set the rect of the group to the rect of the card/stack
3. Enable the horzontal and vertical scrollbars for the group
Et voila, a scrollable image

Check the attached stack, one (not too) big image of a christmastree which is grouped.
And check the script of the card to see the "resizestack" script"
Best
Klaus
- Attachments
-
- scroll_large_image.rev.zip
- (278.28 KiB) Downloaded 648 times
Re: How to open large size image
Thank Klaus. This seems like an excellent solution
.
I wonder that could we resize the image when the size of card is changed by user?

I wonder that could we resize the image when the size of card is changed by user?
Re: How to open large size image
Hi Linh,
my pleasure
Sure, resizing is simple!
The "resizestack" message (see the dictionary) comes with 4 parameters:
new width, new height, old width, old height
So you can compute the necessary dimension for the image from this info.
Or use "the rect of this cd" like in my example stack.
Check "the formattedwidth of img X" and "the formattedheigth of img X" to get the actual dimension of the image.
Be sure to keep the aspect ration in your scripts!
I use a function that gives me the new dimensions for a image:
So you can script "on resizestack" like in the attached stack, see card script
Best
Klaus
my pleasure

Sure, resizing is simple!
The "resizestack" message (see the dictionary) comes with 4 parameters:
new width, new height, old width, old height
So you can compute the necessary dimension for the image from this info.
Or use "the rect of this cd" like in my example stack.
Check "the formattedwidth of img X" and "the formattedheigth of img X" to get the actual dimension of the image.
Be sure to keep the aspect ration in your scripts!

I use a function that gives me the new dimensions for a image:
Code: Select all
## tW = Target width
## tH = Target height
## w = total width of image (100%)
## h = total height of image
function make_ratio tW, tH, w, h
put min (tW/w,tH/h) into tscaleFactor
return round(w * tscaleFactor) & "," & round(h * tscaleFactor)
end make_ratio

Best
Klaus
- Attachments
-
- zoom_large_image.rev.zip
- (278.56 KiB) Downloaded 267 times
Re: How to open large size image
Thank Klaus so much!! You're so nice 
