I need to crop camera pictures to go into square image fields in a screen full of square buttons. There is no room to put the boundary rectangles on the final screen, so I have to be able to crop the image on one card, then move the result to an image field on another card.
In playing around with the crop command, I made a simple stack with two image fields and one button. The button code looks like this:
on mouseUp
iPhonePickPhoto camera, 400, 300
put last image into image "initialPic"
delete last image
crop image "initialPic" to the rect of graphic "Boundary"
put image "initialPic" into image "finalPic"
end mouseUp
When I run this on an iPad, the cropped image appears in the 'initialPic" field exactly as expected, but the "finalPic" field remains empty. So it seems that a cropped image loses its identity somehow and can't be addressed.
Can anyone shed some light on this?
TIA
Don
Can't access a cropped image?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Can't access a cropped image?
Hi Don,
From what you describe, it looks like the text property is cleared when you crop the image. When you put img 1 into img 2, you're actually copying the text property (which is the data in PNG, JPEG, BMP or raw format). I'm pretty sure that the imageData is still there. You should be able to set the imageData of img 2 to the imageData of img 1 and see what you expect.
Kind regards,
Mark
From what you describe, it looks like the text property is cleared when you crop the image. When you put img 1 into img 2, you're actually copying the text property (which is the data in PNG, JPEG, BMP or raw format). I'm pretty sure that the imageData is still there. You should be able to set the imageData of img 2 to the imageData of img 1 and see what you expect.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Can't access a cropped image?
Hi Mark
Yes, that does exactly what I need - many thanks.
One other question you may be able to help with: When the Pick Photo window comes up, accidentally touching any part of the screen outside that window causes the app to close. In a similar situation in the main app when getting a pic from the library, I put a graphic with transparency set so that it is invisible but still responds to a touch. The handler then simply drops the app back to the previous card to start the pick process again.
In this situation that is not a very elegant solution and I wonder if there is a better way to handle it.
Cheers
Don
Yes, that does exactly what I need - many thanks.
One other question you may be able to help with: When the Pick Photo window comes up, accidentally touching any part of the screen outside that window causes the app to close. In a similar situation in the main app when getting a pic from the library, I put a graphic with transparency set so that it is invisible but still responds to a touch. The handler then simply drops the app back to the previous card to start the pick process again.
In this situation that is not a very elegant solution and I wonder if there is a better way to handle it.
Cheers
Don