Results 1 to 2 of 2

Thread: On memory png data

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default On memory png data

    Hi,

    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?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: On memory png data

    Qt Code:
    1. QByteArray bytes;
    2. QBuffer buffer( &bytes );
    3. buffer.open( QIODevice::WriteOnly );
    4. image.save( &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();
    2.  
    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, 14:38
  2. Memory aligned QVector().data()
    By sto in forum Qt Programming
    Replies: 10
    Last Post: 19th November 2010, 10:30
  3. memory leak when copying Qimage data
    By klobauster_toomc in forum Qt Programming
    Replies: 2
    Last Post: 25th February 2010, 09:33
  4. QPixmap: X11 "memory leak" due to shared pixmap data?
    By chezifresh in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2009, 20:53
  5. Corrupt JPEG data: premature end of data segment
    By node_ex in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2008, 09:57

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.