Results 1 to 2 of 2

Thread: problem with Recieving grayscale

  1. #1
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default problem with Recieving grayscale

    Hi,
    My program is designed to receive a gray scale image from external media. My media is sending a proper gray scale image byte by byte. But while receiving in my program Qt will convert it to 8 bit color. That is, i am using following function to receive it.
    QImage image = QImage((uchar*)DataValues.data(), 300, 300, QImage::Format_Indexed8);

    Here Datavalues is of type QByteArray.

    Can any one please tell me how can i receive the gray image as grayed itself.???


    Thank You

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Recieving grayscale

    The docs say:
    Constructs an image with the given width, height and format, that uses an existing memory buffer, data. The width and height must be specified in pixels, data must be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned.
    The buffer must remain valid throughout the life of the QImage. The image does not delete the buffer at destruction.
    If format is an indexed color format, the image color table is initially empty and must be sufficiently expanded with setNumColors() or setColorTable() before the image is used.
    With 300x300 image you fulfill the alignment requirements, but still you have to make sure that DataValues exists long enough and you have to set the color table.

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. Replies: 16
    Last Post: 7th March 2006, 15: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.