Results 1 to 7 of 7

Thread: Read QImage into QMovie

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Read QImage into QMovie

    Hi,

    I need to read a QImage data into QMovie. QImage may contain a gif, png or jpg file.. If i use filepath instead of QImage:

    movie->setFileName("path")

    everything goes well. I couldnt figure out how to do that for QImage. In the following code "state" returns true but "Movie->isValid()" returns false:

    Qt Code:
    1. QBuffer buffer(&ba);
    2. buffer.open(QIODevice::WriteOnly);
    3. bool state= image->save(&buffer,"PNG");
    4. Movie = new QMovie(&buffer);
    To copy to clipboard, switch view to plain text mode 

    Any idea?

    Thanks in advance...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Read QImage into QMovie

    Maybe because your buffer is opened in WriteOnly mode.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Read QImage into QMovie

    Hi, the result is same with ReadWrite mode...

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Read QImage into QMovie

    Have you tried specifying the format?
    Have you tried resetting the buffer's position to the beginning?
    Is there anything you actually tried yourself?

    Cheers,
    _

  5. #5
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Read QImage into QMovie

    Hmm, yeah. I think i tried everything that i could think . No way...

    Qt Code:
    1. QBuffer buffer(&ba);
    2. buffer.open(QIODevice::WriteOnly);
    3. buffer.seek(0);
    4. bool state= image->save(&buffer,"PNG");
    5. Movie = new QMovie(&buffer,"PNG");
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Read QImage into QMovie

    Does it work if you save the image to a file and then you load the movie from that file?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Read QImage into QMovie

    Quote Originally Posted by yagabey View Post
    Hmm, yeah. I think i tried everything that i could think . No way...

    Qt Code:
    1. QBuffer buffer(&ba);
    2. buffer.open(QIODevice::WriteOnly);
    3. buffer.seek(0);
    4. bool state= image->save(&buffer,"PNG");
    5. Movie = new QMovie(&buffer,"PNG");
    To copy to clipboard, switch view to plain text mode 
    seek() before save() makes no sense, the buffer is at 0 because it is empty.

    If you find it difficult to place the seek() after the save, try closing the buffer and re-opening it in read mode.

    Cheers,
    _

Similar Threads

  1. QMovie GIF with MAC
    By Viraj Bhatt in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2012, 15:22
  2. Gif plugin loaded but QImage cant read gif file.
    By spsingh in forum Installation and Deployment
    Replies: 0
    Last Post: 30th July 2010, 13:26
  3. events of QMovie
    By talk2amulya in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 08:54
  4. QMovie
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 24th August 2007, 14:23
  5. Problem with QMovie
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 30th March 2006, 09:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.