What´s wrong with this

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

What´s wrong with this

Post by simon.schvartzman » Sun Jan 29, 2017 3:18 pm

Hi, this is what I want to accomplish running on iOS:

1- rotate an image
2- save it to the camera roll

Please help me identify what´s wrong with the code below . I would expect a left pointed arrow (the rotated image) to be saved to the camera roll but I'm getting the original picture...

Code: Select all

on mouseUp
   set the angle of image "Img1" to the angle of image "Img1" + 90   
   put the long ID of image "Img1" into tImageID  
   mobileExportImageToAlbum tImageID
   answer the result
end mouseUp
Simulator Screen Shot 29Jan, 2017 12.07.29.jpg
Untitled 1.livecode.zip
(2.42 KiB) Downloaded 263 times
Simon
________________________________________
To ";" or not to ";" that is the question

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: What´s wrong with this

Post by richmond62 » Sun Jan 29, 2017 3:57 pm

I don't know anything about work on mobile devices, but I do know something that might help you.

After you have rotated the image, lock it before you send it to the album.

There wasn't much point in uploading that stack as your images are referenced, not embedded.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: What´s wrong with this

Post by richmond62 » Sun Jan 29, 2017 4:06 pm

Hey-Ho.livecode.zip
Modded version of your stack.
(6.52 KiB) Downloaded 300 times
I've embedded an image, and I make sure it is locked after it has been rotated.

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: What´s wrong with this

Post by simon.schvartzman » Sun Jan 29, 2017 4:17 pm

Richmond, many thanks for your inputs...still no joy saving the rotated image...
Simulator Screen Shot 29Jan, 2017 13.13.56.jpg
Simon
________________________________________
To ";" or not to ";" that is the question

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: What´s wrong with this

Post by bn » Sun Jan 29, 2017 4:24 pm

Hi Simon,

when you rotate the image the original image is not rotated, you just rotate the display.

The easiest way would be to take a snapshot as png of the image and put the snapshot into a temporary image and export the temporary image.

If you need help (code) pseudocode for
export snapshot from image "img1" to tTemp as png; set the text of image "temp" to tTemp;
just say so

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: What´s wrong with this

Post by richmond62 » Sun Jan 29, 2017 4:30 pm

You could consider taking a snapshot . . .
Hey-Ho 2.livecode.zip
(6.57 KiB) Downloaded 281 times

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: What´s wrong with this

Post by simon.schvartzman » Sun Jan 29, 2017 4:38 pm

Hi Bernd, many thanks for your help, YES definitely need help with the code...can't make it work.

Best!
Simon
________________________________________
To ";" or not to ";" that is the question

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: What´s wrong with this

Post by simon.schvartzman » Sun Jan 29, 2017 4:47 pm

thanks Richmond, working like a charm now.

Best regards
Simon
________________________________________
To ";" or not to ";" that is the question

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: What´s wrong with this

Post by Klaus » Sun Jan 29, 2017 6:27 pm

One could also take a quick look into the dictionary, which often gives the missing informations!
From the entry about "angle":
...
Unlike the rotate command, the angle property affects only the screen display of the image, not the actual picture data in it.
Changing an image's angle does not change the imageData of the image.
...
8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10127
Joined: Fri Feb 19, 2010 10:17 am

Re: What´s wrong with this

Post by richmond62 » Sun Jan 29, 2017 6:39 pm

a quick look into the dictionary
Now why would one want to do that?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: What´s wrong with this

Post by bn » Sun Jan 29, 2017 7:49 pm

Changing an image's angle does not change the imageData of the image
Err, imageData is actually changed. ImageData is what is rendered on screen. That is why you can make changes to an image like changing the dimensions of an image or angle make permanent by doing

Code: Select all

set the imageData of image "myImage" to the imageData of image "myImage"
Which sounds a bit nonsensical but it is the way to make those temporary changes to an image stick.

I am not quite sure but it seems by doing that (setting imageData to imageData) the image looses some specific format information necessare for PNG or JPG. The way to restore that information to make it a fullblown PNG or JPG is to use export image --- as PNG or JPEG, or just do a snapshot in the format you want.

KInd regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: What´s wrong with this

Post by bn » Sun Jan 29, 2017 7:55 pm

@Simon

Simon could you please use more descriptive headlines for your postings. Otherwise the whole discussion is unlikely to be of use to someone searching the forum.

"What's wrong with this" is not very specific. Although I ask exactly that same question myself all day when coding... :)

Kind regards
Bernd

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: What´s wrong with this

Post by simon.schvartzman » Sun Jan 29, 2017 7:58 pm

will do so.
Simon
________________________________________
To ";" or not to ";" that is the question

Post Reply