-1

Why can't I load this png into my QPixmap? Open street map png

Q_ASSERT(fakeMap.load("C:/map71.png"));

This renders an ASSERT.

Does not render an ASSERT if I open it in MS paint and re saves it either as a jpeg or png (but larger in size). Same path and syntax.

Civing
  • 353
  • 3
  • 12

1 Answers1

3

The image you link to is actually a JPEG. If I save it with the jpg extension it loads into Qt ok. Qt is probably trying to treat it as a PNG and that's why it's failing.

Dan Milburn
  • 5,600
  • 1
  • 25
  • 18
  • You are right.. This also works: Q_ASSERT(fakeMap.load("79.png", "jpg")); – Civing Nov 07 '12 at 17:58
  • Maybe Qt should be able to scan the image header in a better way and not just rely on the file extension? – Civing Nov 07 '12 at 17:59
  • 1
    According to [QPixmap documentation](http://doc.qt.digia.com/qt/qpixmap.html#load), the format _is_ tried to guess from the header. But it seems that the guessing is not perfect. –  Nov 07 '12 at 19:32