How to deal with a snapshot?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7397
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to deal with a snapshot?

Post by jacque » Mon Apr 23, 2012 3:07 am

the user has the choice of putting text into a button instead of a picture
How long is the text? If it isn't too long, you could just set the label of the button to the text. Even if you don't do that, you should be able to manipulate the button layer the same way you do the image now. If I understand things right, it should be a straight swap for the layering part.

I wasn't following the image discussion closely but it seems like the solutions suggested should work, since there isn't anything different about the image the camera command creates, it's just a regular LiveCode image. I probably won't get a chance to test but maybe some one else will. Dixie is usually right on the ball, so there may be something different about your own stack or scripts that's causing a conflict.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: How to deal with a snapshot?

Post by grovecat » Mon Apr 23, 2012 1:47 pm

The text has be automatically centered, both horizontally and vertically. I can do that with a text field but not with a button.
I did belatedly realise that I can simply treat the buttons as image areas and manipulate the layers as I am doing already.

This saga is becoming a bit convoluted, so I'll try to outline the story so far.

The user of my app can load photos into several different square image areas on different cards. They have to be square for reasons I don't need to bother with here. Up until recently those have all been pictures of album covers downloaded from the web and put into the iPad camera roll. They are always square, so I set the iPhonePickPhoto command to ask for a square image such as with iPhonePickPhoto library, 300,300. The app puts the last image into a global variable and from there puts it into the various image areas. As the photos are themselves square there has been no problem. And I should mention that the images are part of the user data and I save them as jpg files in the caches folder under session names. So far so good.

Now the user wants to access photos that are in standard 4 x 3 format from either the library or the camera, but still placed into the square image areas (that is, cropped). When this happens, although the iPickPhoto command asks for a square image, what is actually returned is one in 4 x 3 format. For example, the above command is set to 300, 300 but it will return an image that is 400 x 300. When that is put into a square image area it is squashed horizontally and thus distorted.

I therefore had a look at the crop command as that seemed to offer a solution. However, a cropped image cannot be "put" into another image area as I mentioned in the topic "Can't access a cropped image". So I was not able to put it into the required image areas in the app. Mark suggested that I use the set imageData command, which at first seemed to be the answer. However, it does not work when the two image areas are different sizes as I mentioned in the topic "Cropping and Image Data Woes".

In a response to that post, Klaus recommended using the snapshot command instead. Unfortunately the same problem arose with that in trying to place the image into other image areas, leading to the current thread. I have tried all the ideas here and have essentially always come up against the same problem -- I can't get a cropped image into other image areas.

The button id technique suggested by Jacque looks promising. However, I am a bit concerned by the statement ".. the icons are all set immediately after import. They will persist until you either delete the image or change the icon later." As the app is placing multiple images, what happens to first one when the next one becomes the new last image? Will each successive image cause the previous one to be deleted? If not then I can do what is needed with the button id system.

But after all this the main question remains unanswered: Is it possible to somehow put a cropped image (obtained by any method that works) into other image areas? None of the things I have tried have worked so either I am missing something so fundamental that everyone else takes it for granted, or it really is a bit hard.

My sincere thanks to all the patient people who have taken the trouble to advise me on this.

Cheers
Don

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: How to deal with a snapshot?

Post by grovecat » Mon Apr 23, 2012 2:20 pm

I have ascertained that in fact the previous button icon is not deleted when you load another one. So I will be able to use that technique.

Thanks Jacque

Cheers
Don

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How to deal with a snapshot?

Post by Dixie » Mon Apr 23, 2012 3:02 pm

Hi Don...

This will give you an 'undistorted' image... place an image on a card and then group it... lock the size and position of the group. The image object will then expand to the size of the image being put into it, but what you see is restricted by the locked rect of the group that contains it...

be well

Dixie
Attachments
cameraNodistort.livecode.zip
(1.99 KiB) Downloaded 245 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7397
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to deal with a snapshot?

Post by jacque » Mon Apr 23, 2012 6:26 pm

I just did some tests. I think the problems you had with library images are bugs. As near as I can tell, "last image" doesn't work with the crop command; the image must be named. That's easy to do by setting the name of the templateImage.

But I could not find any way to move the new image content into any other existing image in iOS (it works fine in the IDE.) I tried different versions of the syntax, naming both images, etc. but couldn't get it to work. It's worth a report to the bug database. Do you want to write to RR or should I?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

grovecat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 99
Joined: Thu Aug 04, 2011 10:32 am

Re: How to deal with a snapshot?

Post by grovecat » Mon Apr 23, 2012 11:51 pm

Dixie - thank you for an elegantly simple solution. I'll only need to group each image and name the group to the same name as its image then tweak the code to address group imageName instead of image imageName. And the rest of the code can stay the same.

Jacque -- thanks for identifying that the problem is a bug. Would you please report it.

Cheers
Don

Post Reply