Page 3 of 3

Re: Image Rotation

Posted: Thu Sep 07, 2017 12:19 am
by bidgeeman
Yes...I tried that stack a while ago and had all sorts of problems with it trying to get it to work properly.
I will revisit though and post my results.
Bidge

Re: Image Rotation

Posted: Thu Sep 07, 2017 12:35 am
by [-hh]
Marginal note (Angle and resize in one step).
  1. In LC Builder one can do that easily.
  2. With an image of screen size one can do that also in LC Script by using javascript in a browser widget. See for example Jonathan's stack "Browser Widget Image Manipulator" in Sample Stacks.
BUT both methods need a computation for the smallest size they need when being rotated (if you wish to resize the parent of the image accordingly). This will be a (small) part of my talk at LC Global in November.

With smaller image sizes one can do that already perfectly in LC Script by accessing the raw imageData. For example my stack "Perspective Image Distortion 1.3.1" (see Sample Stacks) does this for more complicated 4-point-shapes than rectangles.
[There you can set the relativePoints of the control-poly to the rotated points of your image's rectangle.]

Probably in December I'll make a "Fast Perspective Distortion" stack.

Re: Image Rotation

Posted: Thu Sep 07, 2017 12:22 pm
by MaxV
bidgeeman wrote: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 
   # I 
   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
You just need this:
########CODE to copy and paste#######
on scrollBarDrag pvalue
lock screen
# I have the original invisible image called "i1", but I always work wit a copy "i2"
put pValue/100 into sScale
if there is an image "i2" then delete image "i2"
clone image "i1"
set the name of the last image to "i2"
set the width of img "i2" to (round ( (the width of image "i1") * sScale)
set the height of img "i2" to (round (the height of image "i1") * sScale)
set the visible of image "i2" to true
set the imagedata of image "i2" to the imagedata of image "i2"
unlock screen
end scrollBarDrag
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-6#####

Re: Image Rotation

Posted: Thu Sep 07, 2017 1:07 pm
by bidgeeman
Wow...that worked brilliantly MaxV!
I can't place a "grab me" command on the duplicate image as it replaces itself and the code is lost.
Is there a way to stop the image defaulting position to the top left corner each time? I will have a
play around with it and see if I can work it out.
Thanks so much again.
Bidge

Re: Image Rotation

Posted: Thu Sep 07, 2017 1:24 pm
by Klaus
Hi David,
bidgeeman wrote:I can't place a "grab me" command on the duplicate image as it replaces itself and the code is lost.
sure you can't add this to the cloned image in the script? I bet you can! :D

Hint:
...
put "on mousedown" & CR & "grab me" & CR & "end mousedown" into tScript
...
bidgeeman wrote:Is there a way to stop the image defaulting position to the top left corner each time?
Do you want it at the SAME loc(ation) as image "i1"?

Hint:
"binfile" erm, I mean "loc"! :D


Best

Klaus

Re: Image Rotation

Posted: Thu Sep 07, 2017 1:28 pm
by bidgeeman
LOL Klaus :)
I was just thinking about placing the grab me into the script but you beat me to it!
Might try and set image "i1" to the same loc as image "i2" so that they can be both
dragged around.
Thanks
Binfile...errr...Bidge :lol:

Re: Image Rotation

Posted: Fri Sep 08, 2017 9:50 am
by MaxV
bidgeeman wrote:Wow...that worked brilliantly MaxV!
I can't place a "grab me" command on the duplicate image as it replaces itself and the code is lost.
???
When you clone an object, also the code is cloned.
Put all the code you need in the image "i1" and it will be cloned.
Otherwise, put the code in a custom property, for example:

Code: Select all

set the script of image "i2" to the templateScript1 of image "i1"
the custom property templateScript1 of image "i1" contains all.
Do you know what is a custom property? See http://livecode.wikia.com/wiki/Custom_properties

Re: Image Rotation

Posted: Fri Sep 08, 2017 10:06 am
by bidgeeman
Hi MaxV.
Thank you again. The code does get copied you are correct :)
I have struck only one small problem. For some reason the resolution of the original image is degraded and the copy becomes slightly pixelated when using the resize. I Don't know what could be causing it?
Bidge

Re: Image Rotation

Posted: Sun Sep 10, 2017 12:58 pm
by richmond62
original image is degraded
This has been an ongoing problem with Livecode since the extinction of the dinosaurs,
and, at the moment at least, the way to go would seem to be with SVG widgets.

Re: Image Rotation

Posted: Sun Sep 10, 2017 8:00 pm
by MaxV
bidgeeman wrote:Hi MaxV.
Thank you again. The code does get copied you are correct :)
I have struck only one small problem. For some reason the resolution of the original image is degraded and the copy becomes slightly pixelated when using the resize. I Don't know what could be causing it?
Bidge
If you enlarge an small image, it gets pixelated. But if the original image is bigger than the resized one, it can't be pixelated.
See also this post (there is a button to translate it in your mother tongue): http://livecodeitalia.blogspot.it/2014/ ... li_88.html .

Re: Image Rotation

Posted: Sun Sep 10, 2017 11:47 pm
by bidgeeman
Hi MaxV.
Once again thanks for your feedback :)
Regards
Bidge

Re: Image Rotation

Posted: Sat Apr 27, 2019 1:42 pm
by jmburnod
Hi All
Hermann said:
There is a stack "Angle and Resize an Image" (by Paul Hibbert) on "Sample Stacks" to that problem.
Yes for an image resized proportionaly mais no for a distorded image.
but I experimented "imageHandles89_v110" from hh and it works for this goal :D
You may download it on sample stacks
Thanks again Hermann
Jean-Marc