Results 1 to 3 of 3

Thread: removedddddd

  1. #1
    Join Date
    Dec 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Unhappy removedddddd

    #####removed#####
    Last edited by PatrickGezzi; 15th December 2013 at 19:39. Reason: removing

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Display a Image from File with uchar-Values?

    Just to be sure: the file you are reading was written using QDataStream, right?

    Have you tried writing the read image to disk? I.e. calling a.save() after the two loops?

    Cheers,
    _

  3. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Display a Image from File with uchar-Values?

    I see some problems with your LoadImage() code snippet:

    (1) The images list will contain only one image and it will contain bogus or a trash. The variable b is set to 1 (use bool for it), then the image is appended to the list, then it is filled by pixels and then the while cycle is exited. imageNumber should be 1 and the images list will contain the image before filling.
    (2) Reading the data values is shifted. C++ fields are indexed starting from zero, therefore
    Qt Code:
    1. colors=qRgb(data.value(0),data.value(1),data.value(2));
    To copy to clipboard, switch view to plain text mode 
    (supposing the data contain RGB triplets. If they are ARGB then, really, data(1), data(2), data(3) but you need to remove 4 bytes).
    (3) The removeFirst() method can be really expensive. I suggest:
    Qt Code:
    1. int k = 0;
    2.  
    3. for( int i = 0; i < getHeight(); i++ )
    4. {
    5. for( int j = 0; j < getWidth(); j++ )
    6. {
    7. colors=qRgb(data.value(k),data.value(k+1),data.value(k+2));
    8. a.setPixel(j,i,colors);
    9. k += 3;
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 19th July 2018, 06:38
  2. QSpinBox : display values from a QVector
    By CTZStef in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2013, 13:13
  3. Replies: 11
    Last Post: 28th June 2012, 11:17
  4. Replies: 1
    Last Post: 18th January 2012, 10:00
  5. Replies: 0
    Last Post: 21st July 2010, 10:32

Tags for this Thread

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.