Results 1 to 5 of 5

Thread: Almost reading QImage line by line, help me please.

  1. #1
    Join Date
    Jul 2008
    Posts
    18
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Cool Almost reading QImage line by line, help me please.

    Qt folks

    Im trying to open a image file and display it line by line, after i get this working i want the line by line image data to be sent over the network to another system and have a qt app display this image data line by line on a QGraphicsScene. I think im almost there as far as showing the image data line by line, im just not sure if im getting the correct values in my test app, this is a small application can anyone tell me if im on the right track here?
    I dont think this example is correct. At this point i just want line by line image data. Im not to worried about how to transfer it over the network yet, but i will need to send it in chunks of like 20 lines at a time over a socket. Here is a small example using a qt4 image.

    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include <iostream>
    4.  
    5. using namespace std;
    6.  
    7. int main (int argc, char *argv[])
    8. {
    9. QApplication app (argc, argv);
    10. QImage* pImage = new QImage("/images/qt4.jpg");
    11.  
    12. for ( int line = 0; line < pImage->height(); line++ )
    13. {
    14. for ( int pos = 0; pos < pImage->width(); pos++ )
    15. {
    16. cout << pImage->scanLine(line) << endl;
    17. cout << pImage->scanLine(pos) << endl;
    18. }
    19. }
    20. return app.exec ();
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 21st July 2008 at 18:45. Reason: missing [code] tags

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Almost reading QImage line by line, help me please.

    why do you iterate over columns (pos, width), too, if all you want is scan lines?

  3. #3
    Join Date
    Jul 2008
    Posts
    18
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: Almost reading QImage line by line, help me please.

    Well now im looking at it and asking my self the same question, how do i get a single line? Is that a single row?

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Almost reading QImage line by line, help me please.

    I don't have used that stuff myself, but I would assume that
    Qt Code:
    1. pImage->scanLine(line)
    To copy to clipboard, switch view to plain text mode 
    gives you the data for line i.

    Note, however that this data in all probability will be binary.
    Just writing it to cout (probably) won't work, unless you tell that stream to work on binary data.

  5. #5
    Join Date
    Jul 2008
    Posts
    18
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Almost reading QImage line by line, help me please.

    Thanks caduel that worked. The main problem is that i was thinking it had to be harder then then that, qt just makes it simple.

Similar Threads

  1. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  2. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.