GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

Create Button to Rotate GPUImage

Open capitanomikejobs opened this issue 13 years ago • 3 comments

I want to build a button that every time you press rotates the image by 90 °. I tried to do so, but it does not work

(IBAction)Rotate:(id)sender {

staticPictureOriginalOrientation=UIImageOrientationLeft;

[self.imageView setInputRotation:staticPictureOriginalOrientation atIndex:0];

[staticPicture addTarget:filter];

[staticPicture processImage];

}

what I get is this

Tap Button +90° rotate image and processImage

capitanomikejobs avatar Mar 10 '13 16:03 capitanomikejobs

Your code there only rotates it once. Also, you're using the wrong type of enumeration there. -setInputRotation: takes a GPUImageRotationMode enumeration, the possible values for which are kGPUImageNoRotation, kGPUImageRotateLeft, kGPUImageRotateRight, kGPUImageFlipVertical, kGPUImageFlipHorizonal, kGPUImageRotateRightFlipVertical, and kGPUImageRotate180.

You need to have your rotation change in stages, based on what the previous rotation value was.

BradLarson avatar Mar 10 '13 23:03 BradLarson

Thank you so much for your reply but I can not figure out how to use it Could you tell me how to do the button to rotate 90 degrees for each TAP.

capitanomikejobs avatar Mar 11 '13 15:03 capitanomikejobs

As I said above, you need to have a conditional statement (most likely a switch) that changes the input orientation applied to the view based on what it was previously. You need to swap these out in consecutive 90 degree steps with each press of the button. I'll leave it to you to order these properly.

BradLarson avatar Mar 11 '13 20:03 BradLarson