Results 1 to 2 of 2

Thread: On memory png data

  1. #1
    Join Date
    Jan 2006
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Thanked 58 Times in 56 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows

    Default On memory png data


    I want to create a PNG structure from a buffer pointer.

    What I want to do is to store PNG files into MySQL database in a BLOB column. The data for create the PNG file comes from a USB camera.

    What I don't want to do is to get the camera data, write into a file, open the file and write the file data into database because writing and reading from a file will slow down speed(high speed will be needed).

    So, how can I get the PNG compressed structure into memory without using a file? Maybe have I to create a memory file? Is that possible?

    Òscar Llarch i Galán

  2. #2
    Join Date
    Apr 2011
    Thanked 13 Times in 13 Posts
    Qt products
    Unix/X11 Windows

    Default Re: On memory png data

    Qt Code:
    1. QByteArray bytes;
    2. QBuffer buffer( &bytes );
    3. QIODevice::WriteOnly );
    4. &buffer, "PNG" );
    To copy to clipboard, switch view to plain text mode 
    And write bytes in DB. (This load from exist image)

    Load from BD:
    Qt Code:
    1. QByteArray loadImage = q.value(0).toByteArray();
    3. if (!loadImage.isEmpty())
    4. {
    5. QImage img;
    6. img.loadFromData( loadImage );
    7. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Jonny174 for this useful post:

    ^NyAw^ (20th December 2012)

Similar Threads

  1. Replies: 0
    Last Post: 10th September 2011, 13:38
  2. Memory aligned QVector().data()
    By sto in forum Qt Programming
    Replies: 10
    Last Post: 19th November 2010, 09:30
  3. memory leak when copying Qimage data
    By klobauster_toomc in forum Qt Programming
    Replies: 2
    Last Post: 25th February 2010, 08:33
  4. QPixmap: X11 "memory leak" due to shared pixmap data?
    By chezifresh in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2009, 19:53
  5. Corrupt JPEG data: premature end of data segment
    By node_ex in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2008, 08:57


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.