# My pixel perfect picture gets blurry when compiled in LaTex

Here's my problem.

I have this picture: http://dl.dropbox.com/u/3394117/Temp/fig1.png (I have the original in Pixen and could export it to several different formats. I went with png though since it's lossless.)

Anyhow. When I open my picture in Preview (OS X) and zoom in, it looks fine. The characters have extremely sharp boarders between them and the background. However, when I put it into my latex document, compile it to a pdf (using TexShop) and then zoom in, it suddenly have gotten blurry (see screenshot: http://dl.dropbox.com/u/3394117/Temp/Screen%20shot%202011-02-13%20at%2012.46.30.png).

Minimal working example:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[scale=1]{fig1.png}
\end{document}


In the end, I would like to be able to scale the picture freely without there being any blurring at all.

Does anybody have any solution to my problem?

-

## migrated from stackoverflow.comFeb 13 '11 at 13:12

This question came from our site for professional and enthusiast programmers.

–  Stefan Kottwitz Feb 13 '11 at 13:18
Dan: The screenshot works now. Thank you for pointing that out. –  Speldosa Feb 13 '11 at 15:43
Stefan: Thank you for those links. I will check them out. –  Speldosa Feb 13 '11 at 15:44

This is just an effect of the display settings of your PDF viewer. In Acrobat Reader 9, for example, there is an option "Edit | Preferences | Page Display | Smooth images". If you uncheck this box, the picture will not be anti-aliased. When printing, your image should look fine regardless of the smoothing effect you see on screen.

Here's your file in Acrobat Reader 9, zoomed to 800%, left half with the default "Smooth images", right half with the option unchecked. Note the tick mark and the red X:

-
OMG! :) Well that exaplains a lot. Still I'm using PDF to actually be able to control how everybody else sees my content. Nice to know that the print wouldn't be affected anyway. –  Speldosa Feb 13 '11 at 15:41
I was now asking on comp.text.tex about a pdftex or PDF setting which can be used in the document to tell the PDF viewer not to use anti-aliasing. –  Martin Scharrer May 17 '11 at 21:59

Here is a comparison on my system of the PDF output side by side with your original PNG. The PDF is on the left and the PNG on the right. I can see some slight differences, but I would not describe the PDF as blurrier.

PNG may be lossless, but it's still a bitmap format, and hence will look bad when zoomed in on, especially for a very small image like yours. Does Pixen have the option for exporting to a vector format, like EPS or PDF (or SVG, which you could then convert using other tools)? That would be better than PNG.

-
+1 for vector formats. If you're feeling hardcore, redraw the whole thing in TikZ... –  Seamus Feb 13 '11 at 13:45
Yes, it can export to for example ESP. However, when I do that, I get the same result. I have to admit that I don't really understand how different images are handled. For example, if I import the picture to Pages (iWork) and make it bigger, before I release the mouse it looks exactly like I want it (no blurryness at all, sharp boarders et cetera) but when I release the button, it gets blurry as if Pages wanted to "help" me somehow. Guess the same thing is happening in LaTex...or? Anyway. I solved it in an ugly way (see solution suggestion from myself). –  Speldosa Feb 13 '11 at 13:55
@Speldosa: That behaviour in Pages is the "display smoothing" again: Pages assumes that you don't want to see the hard edges of your pixels and tries to make it look pretty by smoothing over it, which would be fine for photos, but not for pixel art. The underlying picture is fine, it really is just a display option of the picture viewer (or the PDF viewer if the image is included in a LaTeX document). –  Jake Feb 13 '11 at 13:59
@Jake: Oh, I see. Then I guess it is preferable to do something along the lines with what I did (make the picture bigger) to get it to be shown properly for most people. –  Speldosa Feb 13 '11 at 14:01
@Speldosa, I'd guess that Pixen is just putting a bitmap graphic in an EPS wrapper. Try importing into an actual vector graphics editor that has vectorize/trace capabilities like Inkscape -- I do think it's the viewer making the difference, but I still think vectorizing it would help. –  frabjous Feb 13 '11 at 14:03

Ok. I got it to work now. It was ugly but it works.

What I did was the following. I zoomed in on the picture in Pixen so that it covered my entire screen. I then took a screenshot, imported it into Pixelmator and exported it as a png-file.

Now it looks great! It's not until you zoom in really, really far that you notice the blurring.

It would be neat to be able to zoom without getting any blurring at all. Maybe I should do vector pixel art next time (I'll see if InkScape can fulfill my needs).

-
Isn’t Jake’s answer more apt? I.e. disable the smoothing setting in your PDF viewer? –  Konrad Rudolph Feb 13 '11 at 14:23
@Konrad: Well, if you send the pdf file to someone else, they might be rather annoyed if they're told to change viewer settings for best onscreen viewing. –  Hendrik Vogt Feb 13 '11 at 14:34
@Hendrik True, but this is a limitation (and, in my opinion, plainly a bug) in the viewing software and this workaround may not work as expected in some other viewers. In fact, the fact that this workaround works at all is probably also a bug that may get fixed some time in the future. –  Konrad Rudolph Feb 13 '11 at 14:50
That will definitely help if you have to keep using a raster format -- you can always scale them down to fit the available size without losing visible quality. –  Mike Renfro Feb 13 '11 at 15:26
I still don't see why my solution wouldn't always work. What I've done is to effectively heightened the resolution of my picture so that it, when it is presented as a smaller image, will be able to show the picture without blurring. If I however send my PDF to someone else and this person don't know how to goof around with the PDF reader, then I'm pretty much screwed. –  Speldosa Aug 3 '11 at 15:13