Rescaling a selected image from album on Android

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

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Rescaling a selected image from album on Android

Post by Tukcedo » Tue Sep 02, 2014 10:46 am

[Sigh] You old pirate you ;-) ;-)

Would strict checking catch this, as it does in Perl and other lingoes?
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Rescaling a selected image from album on Android

Post by Simon » Tue Sep 02, 2014 6:04 pm

Yes, but now I'm confused.
From the Main menu Edit > Preferences > Script Editor select Strict Compilation Mode
or
From the Script Editor menu Edit select Variable Checking
I know the second one works. Is it the same as the first one?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Rescaling a selected image from album on Android

Post by Tukcedo » Tue Sep 02, 2014 8:09 pm

First the good news: the delete now works and it fixes the situation of overlapping or non-resizing images. Left to do: Android reverses portrait and landscape (i.e. camera landscape = image portrait)

Hmmm don't think so: I'm getting different results for the "preferences" and the "variable checking" methods. The 2nd one seems stricter. I've declared a "local cProfileImage" at the top of the card script. Variable checking complains about the code snippet below with:

card "UserProfile": compilation error at line 28 (Chunk: can't create a variable with that name (explicitVariables?)) near "MaxHeight", char 12

whereas Preferences remains entirely happy (No errors occurred). Dunno what it's complaining about to be honest. Perhaps we should split into a new subject ...

Code: Select all

         # an image was selected
         put the formattedHeight of the last image into W
         put the formattedWidth of the last image into H
         set the name of the last image to "cProfileImage"
         set the lockLoc of image "cProfileImage" to true
         set resizeQuality of image "cProfileImage" to "good"
         
         put W / H into AspectRatio
         put round(MaxHeight * AspectRatio) into NewWidth
         answer "W x H = " & W && "x" && H && "(" & AspectRatio & ")" & return &  "New:" && NewWidth && "x" && MaxHeight with OK 
         
         lock screen
         # first set the new dimensions
         set the height of image "cProfileImage" to MaxHeight
         set the width of image "cProfileImage" to NewWidth
         # then position the scaled image
         set the left of image "cProfileImage" to 40
         set the top of image "cProfileImage" to 300
         unlock screen
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Rescaling a selected image from album on Android

Post by Simon » Tue Sep 02, 2014 8:42 pm

:)
card "UserProfile": compilation error at line 28 (Chunk: can't create a variable with that name (explicitVariables?)) near "MaxHeight", char 12
You'll now have to list all of your variables upfront just like you did with cProfileImage.

I think I have seen the flipped landscape/portrait but I don't recall a solution.

Simon
Edit; No I am wrong.
Variable checking causes LiveCode to perform a stricter check
of your scripts. Using any variable without declaring it first, or
using a literal string without encloning it in quotes causes a
compile error. This behavior can be useful in tracking down
certain subtle problems such as misspelling a variable name.
So that isn't going to help catch spelling mistakes :(
Edit 2; in your strings.
Last edited by Simon on Tue Sep 02, 2014 8:53 pm, edited 2 times in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Re: Rescaling a selected image from album on Android

Post by Tukcedo » Tue Sep 02, 2014 8:47 pm

Playing with that rotate/angle stuff right now, but this "flipping" thing is pretty resilient it appears ;-) When I get to grips with it I'll post of course. Thanks a zillion so far!
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”