Results 1 to 7 of 7

Thread: Bitmap to byte array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    2

    Default Re: Bitmap to byte array

    Thx for the reply.

    At the moment I have problem with getting RGB values.

    Qt Code:
    1. ...
    2. QImage image(fileName);
    3. image = image.convertToFormat(QImage::Format_RGB32);
    4. ...
    5. for (int j = 0; j < 640; j++ ){
    6. QRgb tempColorRgb = bitmap.pixel(QPoint(j,row));
    7. QColor tempColor(tempColorRgb);
    8. buffer[j] = (tempColor.red() & 0xE0>> 16) | (tempColor.green() & 0xE0 >> 8) | tempColor.blue() & (0xC0 >> 6);
    9. }
    To copy to clipboard, switch view to plain text mode 

    This should read and store to buffer one row of image. Image is opened correctly but data in buffer is not correct. For example for one color bitmap it gives almost random values (smth like 8 pixels blue then 12 black then 11 yellow etc). Diffrent images gives different results. I also tried different formats with no effect.
    What am I doing wrong?
    Last edited by Otherside; 15th January 2012 at 02:39.

Similar Threads

  1. Cast QString array to std::string array
    By Ishtar in forum Newbie
    Replies: 4
    Last Post: 15th July 2011, 09:28
  2. Replies: 2
    Last Post: 12th November 2010, 15:42
  3. PlEASE HELP: Hot To Use Byte Array, data stream
    By aash_89 in forum Qt Programming
    Replies: 7
    Last Post: 16th July 2010, 09:33
  4. declare an array of QSemaphore and array of slot functions
    By radeberger in forum Qt Programming
    Replies: 11
    Last Post: 2nd May 2010, 14:24
  5. Replies: 3
    Last Post: 19th April 2010, 15:16

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
  •  
Qt is a trademark of The Qt Company.