Downloading a gif, storing it to a QPixMap and playing it with QMovie
-
wrote on 11 Sept 2013, 11:55 last edited by
So i have a function that downloads any image from the internet and stores it to a QPixMap.
What i want to do, is to check if the image is a gif image, then instead of setting a qpixmap to a label, set a qmovie to the label and play it..
so my code is like this:
@if(originalPixmap.toImage().text().right(3)=="gif")
{
processing_request = new QMovie(this);
processing_request->setFileName(originalPixmap.toImage().text());
ui->label->setMovie(processing_request);
processing_request->start();
}
else
ui->label->setPixmap(originalPixmap);@if the image is for example jpg,
@originalPixmap.toImage().text().right(3) @
outputs
"jpg"but when its a gif, it outputs an empty string and here is were i stuck...
One solution would be to save the gif as file, and then set the filename to it's location but i want to avoid saving the image and then deleting it blablabla...
Any ideas?
-
wrote on 11 Sept 2013, 21:06 last edited by
Even if you had success with QImage::text(), and I am not sure if that function even does what you expect it to, a "gif" does not imply an animated image.
Personally, I would take a look into the gif file format and find out how to check for multiple images in one file. But that could become somewhat messy. The idea would be to find out if there is more than a single image in whatever file you want to display.
What happens if you hand a simple image to QMovie? Does it even complain? If so, could you use that to find out if your image would be better displayed as an image instead of a movie?
Sorry that I can't give more detailed help, but I haven't really played around with QMovie yet.
-
wrote on 12 Sept 2013, 11:35 last edited by
[quote author="thEClaw" date="1378933611"]Even if you had success with QImage::text(), and I am not sure if that function even does what you expect it to, a "gif" does not imply an animated image.
Personally, I would take a look into the gif file format and find out how to check for multiple images in one file. But that could become somewhat messy. The idea would be to find out if there is more than a single image in whatever file you want to display.
What happens if you hand a simple image to QMovie? Does it even complain? If so, could you use that to find out if your image would be better displayed as an image instead of a movie?
Sorry that I can't give more detailed help, but I haven't really played around with QMovie yet.[/quote]
That didn't help at all. :?
I don't care if it is one image and secretly its a gif.. play it as a movie as well.The thing is how?
2/3