Results 1 to 3 of 3

Thread: How to construct Image from Bytes

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question How to construct Image from Bytes

    Hi All,

    I m using Qt 4.2.2 on my MAC Intel.
    Eariler I m using qt 3.3 in which I stored bytes in QBytes Array as-

    unsigned long SizeToRead=ThumbnailSize+512;
    unsigned long BytesToIgnore=TStart%512;
    QByteArray qBuffer(SizeToRead-BytesToIgnore);


    But when I m using this in Qt 4.2.2 it is giving the error that
    Invalid Conversion from Long Unsigned Int to const char*.

    Now I m using this.....

    QByteArray qBuffer;
    memset(&qBuffer,0x00,(SizeToRead-BytesToIgnore));


    and also copy the bytes in qBuffer.

    In Qt 3.3 I m using
    QImage image(qBuffer) to construct image from the Bytes but when I m using this in QT 4.2.2 it is giving the following Error that..

    Call of overloaded QImage(QByteArray&) is ambiguous.

    Plz help me How I stored the bytes and construct the image from that.

    thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to construct Image from Bytes

    I do this aswell, but I had to put a QImageReader in between:

    Qt Code:
    1. QByteArray array = qry.value(0).toByteArray();
    2. QBuffer buffer(&array);
    3. buffer.open( QIODevice::ReadOnly );
    4.  
    5. QImageReader reader(&buffer, "PNG");
    6. QImage image = reader.read();
    To copy to clipboard, switch view to plain text mode 

    The code did not work unless I opened the buffer explicitly, so don't forget that.

  3. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: How to construct Image from Bytes

    Quote Originally Posted by e8johan View Post
    I do this aswell, but I had to put a QImageReader in between:

    Qt Code:
    1. QByteArray array = qry.value(0).toByteArray();
    2. QBuffer buffer(&array);
    3. buffer.open( QIODevice::ReadOnly );
    4.  
    5. QImageReader reader(&buffer, "PNG");
    6. QImage image = reader.read();
    To copy to clipboard, switch view to plain text mode 

    The code did not work unless I opened the buffer explicitly, so don't forget that.

    Thanks for Reply.
    But What is qry?and how to open buffer explicitly.
    Also Is QImageReader reader(&buffer, "PNG") used to constuct a PNG Image or what?
    If yes then If I donot know what type of Image is this then What Will I do?

Similar Threads

  1. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  2. Fast image drawing/scaling in Qt 3.3
    By eriwik in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2006, 10:45
  3. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 19:01

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.