Cropping and imageData woes

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Cropping and imageData woes

Post by grovecat » Fri Apr 20, 2012 3:38 pm

My app currently gets a picture from the camera or library and puts it into one large image area and two thumbnails, all on different cards. I do this by first putting it into a variable and then putting that variable into the images.

Now I want to crop a picture before placing it, and as I found out via a previous post, it seems it is only possible to access a cropped image via its imageData property. In other words you can't "put" it. You have to set the imageData of the target to the imageArea of the source. However, using imageData does not work when the image areas are different (as implied in the dictionary). Something appears in the target images but it is totally garbled.

So, is there any way I can crop a picture and put it into image areas of different sizes?

TIA
Don

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

Re: Cropping and imageData woes

Post by Klaus » Fri Apr 20, 2012 4:43 pm

Hi Don,
So, is there any way I can crop a picture and put it into image areas of different sizes?
yes, do not use the CROP command :D

Do this instead, I do this for years:
Import a snapshot of the image area you need*** and use that new (not cropped, but correct size anyway :-) ) and FRESH image for any further action!
The user will not be able to tell the difference!

*** import snapshot from rect (the rect of grc "your reference object here") of img "the newly imported one"
You may want to set the topleft of your image to 0,0 so you can easily calculate the area "to be cropped".

Why struggle with a problem if you can avoid it :-)


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Cropping and imageData woes

Post by jmburnod » Fri Apr 20, 2012 6:14 pm

Hi Don,

Look at the stack in attachment (cd script)

Best regards

Jean-Marc
Attachments
stOpenAndCrop.livecode.zip
(1.35 KiB) Downloaded 307 times
https://alternatic.ch

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Cropping and imageData woes

Post by FireWorx » Fri Apr 20, 2012 8:57 pm

Thats a cool stack...

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

Re: Cropping and imageData woes

Post by grovecat » Fri Apr 20, 2012 11:57 pm

Thanks guys

Klaus, your simple solution is all I need and will do the job nicely. I was not aware of the snapshot command.

Jean-Marc, your elegant script is great, but more than I need for this task.

Cheers
Don

Post Reply