Is there an alternative for using QImage myImage(w, h, QImage::Format_ARGB32);
in Qt? (w
and h
are width and height of imported picture)?
This is the code:
if (tif) {
uint32 w, h;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
QImage myImage(w, h, QImage::Format_ARGB32);
if (!myImage.isNull()) {
if (TIFFReadRGBAImage(tif, w, h, reinterpret_cast<uint32 *>(myImage.bits()), 0)) {
myImage = myImage.rgbSwapped();
myImage = myImage.mirrored();
}
else {
return ImageStatePtr(0);
}
}
TIFFClose(tif);
ImageStatePtr ptr = ImageStatePtr(new ImageState(QFileInfo(filename).fileName(), myImage));
return ptr;
}
else return ImageStatePtr(0);
}
I need to replace QImage with alternative that have the same function. For some reason, i am not allowed to use QImage in my project.
If you want to import an image, you probably want this:
That you can simply use this way:
You can also use a QPixmap instead:
QImage and QPixmap are useful for different tasks. The documentaion says: