0

As of this question/answer, I found that my textures loaded with the wrong sizes because the PNG was saved using a different resolution. Saving them again with another app helps.

My 128x48 PNG was reported to be loaded as 96x36. Resizing the texture by the proper factor draws the pixels correctly. Another file worked properly out of the box. The correct file has a PPI of 72 while the "broken" one has a PPI of 96. Re-saving the broken file with 72 PPI helps.

Why's this resolution a problem? Can we load PNGs independent of the resolution? Or can we determine the resolution after loading and change the image accordingly so I don't have to re-save every image file after editing it just in case?

Community
  • 1
  • 1
ctietze
  • 2,805
  • 25
  • 46
  • Do you know the difference between your "**loaded** with the wrong sizes" and the original question's "some textures **report** their size incorrectly"? Usually, for bitmap-only purposes, the ppi value in a PNG can be ignored. It's actually [totally optional](http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.pHYs) anyway. – Jongware Aug 10 '15 at 09:03
  • Ok, hm! Please help me phrase this more clearly. The file loads fine, but by default it's `size()` _reports_ the wrong dimensions, also it's drawn incorrectly by default. (Since all this is OpenGL-backed, "drawing" means the picture on screen is shrunken down.) I can use this messed-up instance to draw at, say, ~150% and then it's fine. – ctietze Aug 10 '15 at 12:07

0 Answers0