Hello all...
I have an application that loads all its images into a headerless-format in memory (I store width, height, and bpp... and that's enough for OGL textures), but I'm having some difficulty in writing up a "texture manager" using Qt. Whenever I attempt to load in an image from memory, it pops up an QPixmap::convertFromImage: Cannot convert a null image... here's a snippet of what I'm doing:
const Texture * t = myTextures->at(index.row());
QPixmap p
(t
->GetWidth
(), t
->GetHeight
());
bool OK = p.loadFromData((const uchar *) t->GetData(), t->GetSize());
assert(OK);
return QIcon(p.
scaled(60,
60, Qt
::KeepAspectRatio, Qt
::SmoothTransformation));
const Texture * t = myTextures->at(index.row());
QPixmap p(t->GetWidth(), t->GetHeight());
bool OK = p.loadFromData((const uchar *) t->GetData(), t->GetSize());
assert(OK);
return QIcon(p.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation));
To copy to clipboard, switch view to plain text mode
The p.loadFromData() line returns false, which means that it failed to load the image. I've checked with my debugger, and it appears that all my internal texture data is there... is there something else I should be doing?
A breakdown of what's going on: Texture is a class that holds the image. I have a QList of Texture pointers called myTextures. I grab the texture being pointed at by a QModelIndex, initialize a QPixmap with the width and height from the texture, and load from data (memory) the actual texture into the QPixmap.
Bookmarks