cor
cor

Reputation: 627

Pixelart gets fuzzy using UIImageView

I have an 16 * 16 pixel art image which i want to use in my iOS app.
but when i select the image at my UIImageView the picture gets really blurry.

I think it has something to do with the way the image gets filtered, but i couldn't find any filtering options. I already tried changing a lot of options, but just can't get it to work

How do i fix this?

( i am using iOS 7, Xcode 5.1.1, OS X 10.9 Mavericks and a iPhone 4S (i don't think this info is needed, but just in case))

EDIT:

Here's an image: https://i.sstatic.net/d3Yms.png

As you can see, the image on the right in photoshop looks great, but the image on the left in Xcode looks fuzzy

Upvotes: 4

Views: 1167

Answers (1)

kas-kad
kas-kad

Reputation: 3764

The problem is that scaling procedure interpolates pixels position and size while scaling it. If you want to use sharp pixelart-images you must prepare all resources and never rely on scaling by setting

_imageView.contentMode = UIVIewContentModeCenter;

OR set scaling filters to value kCAFilterNearest

[_imageView.layer setMagnificationFilter:kCAFilterNearest];
[_imageView.layer setMinificationFilter:kCAFilterNearest];

if you like the second way, i'd recommend to set all ImageView frames with EVEN (2,4,6,8 etc) sizes and origins to avoid pixel misalign

Upvotes: 6

Related Questions