Page 1 of 1

Cropping and imageData woes

Posted: Fri Apr 20, 2012 3:38 pm
by grovecat
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

Re: Cropping and imageData woes

Posted: Fri Apr 20, 2012 4:43 pm
by Klaus
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

Re: Cropping and imageData woes

Posted: Fri Apr 20, 2012 6:14 pm
by jmburnod
Hi Don,

Look at the stack in attachment (cd script)

Best regards

Jean-Marc

Re: Cropping and imageData woes

Posted: Fri Apr 20, 2012 8:57 pm
by FireWorx
Thats a cool stack...

Re: Cropping and imageData woes

Posted: Fri Apr 20, 2012 11:57 pm
by grovecat
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