Loading static images (png, jpeg) using QImage
I am using Visual Studio 2015 with 32-bit Qt libraries which i built from qt-everywhere-src-5.12.0. Trying to load a static image using QImage.
Receive the following message when i debug :
QImage not loading, Error : <Information not available, no symbols loaded for Qt5Gui.dll>
I tried the same approach in Qt creator and I am able to load the image.
Have used the following code :
Code:
void BqtOglCanvas::drawImage(int width, int height, BmRect imageRect)
{
imgFlag = true;
resultSize
= QSize(width, height
);
paintRect
= QRect(QPoint(imageRect.
pnt1.
x, imageRect.
pnt1.
y),
QPoint(imageRect.
pnt2.
x, imageRect.
pnt2.
y));
}
image->load(fileName);
*image = image->scaled(resultSize, Qt::KeepAspectRatio);
return image;
}
QImage BqtOglCanvas
::getSourceImage() { return sourceImage;
}
{
if (imgFlag) {
imgFlag = false;
QImage sourceImage
= getSourceImage
();
QImage* img
= loadImage
("C:/Users/qu826e/Downloads/ply.png",
&sourceImage
);
const QRect imageRect
= paintRect;
painter.drawImage(imageRect, resImage);
}
}
Any leads will be really helpful.
Re: Loading static images (png, jpeg) using QImage
Quote:
Receive the following message when i debug :
QImage not loading, Error : <Information not available, no symbols loaded for Qt5Gui.dll>
If you really are running a Debug version of your program, it should be reporting "Qt5GuiD.dll". Be sure you are linking with the correct libraries.
QImage::load() returns a Boolean to indicate whether the load succeeded. Why don't you check it before trying to do anything more?
Are you sure the fileName value points to the correct location on disk? Are you passing an absolute path or a relative path?
Is a "image" a non-null pointer to a QImage? You can't call a class method through a null pointer, and "load" will not create a QImage instance.
Re: Loading static images (png, jpeg) using QImage
It's reporting Qt5Guid.dll. Have a doubt regarding the libraries. I built the lib using qt-everywhere-src-5.12.0 using the command : configure -debug -nomake examples -nomake tests -skip qtwebengine –opensource –opengl es2. Does this generate appropriate lib for QImage?
QImage::load() returns a Boolean value true.
fileName value points to the correct location on disk. it as an absolute path.
QImage sourceImage = getSourceImage();
sourceImage comes out to be null.
Re: Loading static images (png, jpeg) using QImage
Quote:
Originally Posted by
avinaskpai12
QImage sourceImage = getSourceImage();
sourceImage comes out to be null.
Code:
QImage BqtOglCanvas
::getSourceImage() { return sourceImage;
}
Where do you fill this (member) variable?
Re: Loading static images (png, jpeg) using QImage
Code:
void BqtOglCanvas::drawImage(int width, int height, BmRect imageRect)
{
imgFlag = true;
resultSize
= QSize(width, height
);
sourceImage = image;
paintRect
= QRect(QPoint(imageRect.
pnt1.
x, imageRect.
pnt1.
y),
QPoint(imageRect.
pnt2.
x, imageRect.
pnt2.
y));
}
filling the variable in drawImage.
Re: Loading static images (png, jpeg) using QImage
You create an empty (uninitialized) image with the size width/height and assign it to sourceImage. Nothing more.
Re: Loading static images (png, jpeg) using QImage
can you help me out with the steps to load the image?
Re: Loading static images (png, jpeg) using QImage
It's pretty simple:
Code:
if ( image.load( filename ) )
{
// If you get here, the image was loaded successfully and is valid
}
else
{
// If you end up here, something went wrong
}