Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Wed Sep 06, 2017 8:41 am
bidgeeman wrote:
Trying to import an image from a folder without using the loc so that it will rotate without distortion. problem is that when I import an image it is larger than the stack so I resize it on import. All good there but when I rotate the image with a slider it pops back to it's original size. How do you overcome this?
Resize the image, then:
Code: Select all
set the imageData of image myImage to the imageData of image myImage
then you can rotate it.
See
http://livecode.wikia.com/wiki/ImageData
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 9:05 am
Hi MaxV.
Please forgive my new user ignorance but when the code refers to "myImage" does that have to be a pathway that refers to an actual image like: image "1" of stack Images? I tried that and it did not work?
Code: Select all
set the imageData of image "i1" of stack "ImageArea" to the imageData of image "i1" of stack "ImageArea"
I am using a slider to rotate the image
Code: Select all
set the angle of image "i1" of stack "ImageArea" to pScrollValue
Bidge
-
Klaus
- Posts: 13829
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Wed Sep 06, 2017 11:01 am
Hi David,
you only need a long descriptor in scripts if the object is not on the current card of the defaultstack!
Don't forget to also add the CARD to it:
... imageData of image "i1" OF CD 2 of stack "ImageArea", if the "target" stack has more than one card!
Best
Klaus
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 11:11 am
Hi Klaus. Yes. the imagage is on a separate card as per the script above but like I mentioned the set ImageData did not work. The image still shrank as it rotated.
Not sure what i did wrong?
Bidge
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 11:17 am
I added the script to the image rotate slider and the image shrank away to nothing!!!
Code: Select all
set the imageData of image "i1" of stack "ImageArea" to the imageData of image "i1" of stack "ImageArea"
set the angle of image "i1" of stack "ImageArea" to pScrollValue
Bidge
-
MaxV
- Posts: 1579
- Joined: Tue May 28, 2013 2:20 pm
- Location: Italy
-
Contact:
Post
by MaxV » Wed Sep 06, 2017 11:52 am
Please see this video, you make something wrong:
https://youtu.be/sSOPwx1YSFw
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 12:38 pm
Ahh MaxV...thank you that worked well. I see that you left the image unlocked. My image was being locked by the code I was using and was not allowing the image to resize itself. I have had to rebuild the code I had originally to accommodate this and it works well for image rotating now but my resizing slider does not retain the last size of the image when it is set by the slider as this was relying on locking the image to the new size. How can I get around this?
Code: Select all
on scrollBarDrag pvalue
lock screen
put pValue/100 into sScale
set the width of img "i1" to the formattedWidth of img "i1"
set the height of img "i1" to the formattedWidth of img "i1"
set the lockloc of img "i1" to false
put the width of img "i1" into sWidth
put the height of img "i1" into sHeight
set the width of img "i1" to (sWidth * sScale)
set the height of img "i1" to (sHeight * sScale)
set the visible of img "i1" to true
unlock screen
end scrollBarDrag
EDIT: I have tried setting the locloc but it keeps reverting back as soon as the locloc is set back to false to allow the image to rotate.
Thanks again
Bidge
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 1:13 pm
Here is my stack.
The resize button will not work if the image has been rotated as well as the image will not retain it's size after being resized.
I don't know what is wrong.
Bidge
-
Attachments
-
- RotateResize.zip
- Rotate Resize problems
- (10.62 KiB) Downloaded 188 times
-
Klaus
- Posts: 13829
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Wed Sep 06, 2017 1:26 pm
Hi David,
use this script for the RESIZE scrollbar:
Code: Select all
on scrollBarDrag pvalue
lock screen
## Setting H and W also changes the LOC!
put the loc of img "i1" into tLoc
put pValue/100 into sScale
## The engine knows these things! :-)
set the width of img "i1" to round(the formattedWidth of img "i1" * sScale)
set the height of img "i1" to round(formattedHeight of img "i1" * sScale)
## So it does not walk around on the card:
set the loc of img "i1" to tLoc
unlock screen
end scrollBarDrag
No need to reset to formattedwidth/height and to un-/lock the size -> loclock
Best
Klaus
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
- Location: Australia
Post
by bidgeeman » Wed Sep 06, 2017 1:30 pm
Hi Klaus.
That works fine but when I try to rotate the image with the rotate slider it pops back to it's original size?
EDIT: Sorry to be a pain but your code locks the image so that the rotation does not work. It's back to the original problem of the image resizing when it rotates.
Bidge
-
bogs
- Posts: 5435
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Sep 06, 2017 1:52 pm
Well, one sure way I can think of is to reduce the size of the image through code to the size you need, lets say 300x200 (works best if all your images are the same size or aspect), then copy it to a temp. folder or variable or container at that size, then import the smaller image.
Alternately, create actual thumbnails of all your images, and load the thumbnail.
-
[-hh]
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Post
by [-hh] » Wed Sep 06, 2017 6:33 pm
As I already wrote a few posts above:
There is a stack "Angle and Resize an Image" (by Paul Hibbert) on "Sample Stacks" to that problem.
shiftLock happens
-
richmond62
- Livecode Opensource Backer
- Posts: 9387
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Post
by richmond62 » Wed Sep 06, 2017 6:59 pm
This is going to sound really corny . . .
If and when I want images to rotate in Livecode, as anything but monochrome svg images screw up in a major way when rotated,
I make pre-rotated images in GIMP and import ALL of them (yeah, yeah, I know that causes an fairly 'expensive' overhead in terms
of hard-drive real-estate) and then call each one at a rotation point.
This guarantees the image comes out without fuzzy-wuzzy-do-dahs, parts of the image mission, resizing of the image and so on.
-
bogs
- Posts: 5435
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Sep 06, 2017 7:26 pm
Why would that sound corny? It is a means to an end, I've used it myself in other languages than this one. Of course, I'll avoid bringing up any reference to some of the things
I've done that
I considered corny, c'est la guerre
-
Klaus
- Posts: 13829
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Wed Sep 06, 2017 7:49 pm
Hi David,
please check the stack that Hermann mentioned a couple of times, you need the workaround described in that stack to make it work!
It just does not work as we exspect it to do!
Here the direct link:
http://livecodeshare.runrev.com/stack/6 ... e-an-Image
Best
Klaus