Results 1 to 3 of 3

Thread: how to draw a image of size 600x400

  1. #1
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default how to draw a image of size 600x400

    hi,

    can anyone say me how to draw an image of size 600x400. i tried as follows
    Qt Code:
    1. QPainter p( this );
    2. uint x,y;
    3. x=550;
    4. y=500;
    5. QImage image(x,y,32 );
    6. image.setAlphaBuffer( true );
    7. for ( uint j =0; j <x; j++ )
    8. {
    9. for ( uint i =0; i <y; i++ )
    10. {
    11. QRgb pixel;
    12. pixel = qRgb(0,0,255);
    13. image.setPixel( i, j, pixel );
    14. }
    15. }
    16. p.drawImage(QPoint(0,0),image,0);
    To copy to clipboard, switch view to plain text mode 

    when i executed this it said the following error:
    "
    QImage::scanLine: Index 500 out of range
    Segmentation fault ".

    but i can succesfuly draw an image of size 500x500.
    can anyone say me why is that so ..

    thanks in advance,

    saravanan

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to draw a image of size 600x400

    Hi,

    seems to that you have to swap i and j:
    Qt Code:
    1. image.setPixel( j, i, pixel );
    To copy to clipboard, switch view to plain text mode 

    Lykurg


    EDIT: or you must say j<y and i<x.

  3. #3
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: how to draw a image of size 600x400

    hi,

    thank you for the reply.now i got it working.

Similar Threads

  1. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 15:39
  2. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36
  3. [QT4] QtextBrowser and image size (win)
    By sebgui in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 22:01
  4. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 23:14
  5. Question about updating an image on screen
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2006, 20: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.