Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Downloading a gif, storing it to a QPixMap and playing it with QMovie

Downloading a gif, storing it to a QPixMap and playing it with QMovie

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leon
    wrote on 11 Sept 2013, 11:55 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thEClaw
      wrote on 11 Sept 2013, 21:06 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on 12 Sept 2013, 11:35 last edited by
        #3

        [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?

        1 Reply Last reply
        0

        2/3

        11 Sept 2013, 21:06

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved