Results 1 to 4 of 4

Thread: QImage and Memoey Mapped Files

  1. #1
    Join Date
    Jul 2010
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QImage and Memoey Mapped Files

    Hi. I want bind QImage to the MMF file to manipulate the image without the cost of memory directly on the disc. Unfortunately, my code creates a copy in memory.

    Qt Code:
    1. QFile file("Boston City Flow.jpg");
    2. if(!file.open(QIODevice::ReadOnly))
    3. QMessageBox::information(this, "Error", "Error");
    4.  
    5. qint64 size = file.size();
    6. unsigned char *mmf = file.map(0, size);
    7.  
    8. QImage image;
    9. image.loadFromData(mmf, size, NULL);
    To copy to clipboard, switch view to plain text mode 

    My program needs to handle very large images.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QImage and Memoey Mapped Files

    Use streams and read/write in smaller packages.

  3. #3
    Join Date
    Jul 2010
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QImage and Memoey Mapped Files

    how? can you give an example for jpeg?

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

    Default Re: QImage and Memoey Mapped Files

    JPEG requires all data to be loaded to be able to manipulate it. mmapping a jpeg would do you no good as the data has to be decompressed and reassembled before it actually becomes an image. You could mmap a BMP file and even maybe an uncompressed PNG file but surely not a JPEG file, regardless if you're using Qt or not.
    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.


Similar Threads

  1. QPixmap/QImage fail to load jpg files in vista
    By schan117 in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 15:48
  2. create Memory-mapped file
    By weixj2003ld in forum Newbie
    Replies: 2
    Last Post: 17th April 2009, 10:47
  3. Support for File Mapped Memory?
    By Jachyra in forum Qt Programming
    Replies: 8
    Last Post: 5th February 2007, 12:44
  4. Replies: 2
    Last Post: 4th February 2007, 22:03
  5. writing CMYK-Files from QImage
    By hilby in forum Qt Programming
    Replies: 2
    Last Post: 27th July 2006, 15:07

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.