views:

295

answers:

2

I am rotating my image with the following code:

CGAffineTransform rotate = CGAffineTransformMakeRotation( [ratio floatValue] );
[imageView setTransform:rotate];

But it doesn't have sharp edges, does someone knows a solution for this?

Here's the link to the image i get: link

+3  A: 

Anytime you do transforms on an image (except in 90° increments) it is going to cause slightly softer edges due to pixel interpolation.

conceptDawg
Oke, but i don't think my image has slight softer edges, it really looks ugly!, could you take a look at the image and tell me if you think its normal? i included the link in my question.
Ton
+2  A: 

The edges of the image itself look jagged because they are being placed into a pixel grid directly, and not being interpolated. Nearest Neighbor Interpolation is the simplest kind of interpolation, where if you have pixel grid A and you move your image to pixel grid B, the pixels in grid B are chosen by simply choosing the closest pixel from grid A. Other forms of interpolation choose a weighted average of the closest pixels to arrive at the pixel value in grid B.

Your image, with its jagged edges, looks like it's using nearest neighbor interpolation, which may be the default type of interpolation on an affine transform on an iphone.

When you use some other interpolation scheme other than nearest neighbor, you'll get aliasing effects, where the subsampling isn't perfect as you transfer from one pixel grid to another. That effect makes edges in the image itself seem blurrier than they otherwise would.

mmr
Thanks for your explaination, but do you know how i can do this in objective c for the iphone.
Ton
Maybe try setting CGInterpolationQuality to kCGInterpolationHigh
mmr
Do you have a example on ho to set that value. I just have my imageView with an UIImage inside it know.
Ton