views:

620

answers:

2

Hello,

I'm tring to implement a digital zoom in an application and I use the following line to change the zoom factor (it can be called many time while the camera interface is displayed):

picker.cameraViewTransform = CGAffineTransformMakeScale(zoomFactor, zoomFactor);

It work perfectly the first time I display the camera inteface but not after that, the transform used by the camera is not the tranform I set. Any idea?

A: 

Not sure I understand exactly what you are doing but I can tell you that transforms are not accumulative unless you feed the existing transform in recursively.

For example, say you have a transform that rotates an object 45 degrees and you want to use it to spin the object. The first time you call it, it rotates the object 45 degrees but it doesn't rotate it any subsequent times. This is because your just setting the same exact transform over and over. A 45 degree transform is always the same.

To make the object rotate you have to call the 45 degree transform then you have to take the resulting transform from the first operation and rotate that by 45 degrees. Then take the results of that and rotate it 45 degrees.

You need to do something like:

picker.cameraViewTransform =CGAffineTransformScale(picker.cameraViewTransform, zoomfactor);

That way, your transforms will accumulate and you can zoom up and down.

TechZen
I don't want my scale tranform to be accumulative and that is why I'm using CGAffineTransformMakeScale. I alloc/init/display the camera picker, set the transform to dynamically change the zoom and then dismiss/release the picker. It work perfectly. The second time I alloc/init/display the camera picker, it's seems that my transform is applied over an existing transform! I don't understand why since I'm using CGAffineTransformMakeScale. Thanks!
Yoshi
The second time you init the picker, does it display the transform you set the first time (even if you don't try to set it again?) If so that would suggest that the picker is a singlton and is not actually being reinitialized. You should post some screenshots so we can see exactly what the problem is.
TechZen
A: 

This isn't so much an answer as a clue. Each time you bring the camera back to the front of the app (presumably using presentModalViewController:) this causes a new transform to be created at cameraViewTransform. The tricky thing is, it seems to take about a second or so for this process to complete, and I can find no delegate method to let us know exactly when the new transform is safely in place. In my app, I end up waiting for about 1 second and THEN modifying the cameraViewTransform to suit my needs. Hacky, but the only solution I've found so far...

Andy Milburn