-4

I have the image data as QByteArray. I want to load the texture of this image from that data using libpng. Everywhere I see reading the image texture from the file or from input stream. But how can I load the image from the QByteArray?? Thanks.

Samuel Harmer
  • 4,264
  • 5
  • 33
  • 67
Tahlil
  • 2,680
  • 6
  • 43
  • 84
  • `bool loadFromData ( const QByteArray & data, const char * format = 0 )` read the docs, they are there for reading – user1095108 Jan 15 '13 at 07:36
  • The real question is: if you're using Qt, why are you trying to use libpng directly? Afaik, the Qt libraries handle png themselves (by using libpng I believe). – Samuel Harmer Jan 15 '13 at 07:50
  • @user1095108 I dont see any method like that in the docs! Thanks for the advice styne666 .I will try it! – Tahlil Jan 15 '13 at 08:10

1 Answers1

0

I found what I wanted in here The png_read_from_mem (png_structp png_ptr, png_bytep data, png_size_t length)' method was exactly what I was looking for. It reads data which isunsigned char*`.

Tahlil
  • 2,680
  • 6
  • 43
  • 84
  • I am not getting a struct from png_get_io_ptr(png_ptr); The subsequent memcpy fails due to invalid address. Do we need to tell it to use a specific io_ptr struct? – azmath Sep 04 '17 at 11:52