Results 1 to 4 of 4

Thread: pixel of Image display

  1. #1
    Join Date
    Jun 2014
    Posts
    33
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question pixel of Image display

    Hi all,

    I am displaying Image that i get from camera on QLabel as QImage,

    How to make sure that the size of QImage is exactly the size i want in Pixel?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: pixel of Image display

    How to make sure that the size of QImage is exactly the size i want in Pixel?
    Qt Code:
    1. QImage image = ...;
    2. int width = ...;
    3. int height = ...;
    4. QImage scaledImage = image.scaled(width, height, ...);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2014
    Posts
    33
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: pixel of Image display

    Erm... i did tried this.
    Qt Code:
    1. frame=cvQueryFram(cam);
    2. cloneFrame=cvCloneImage(frame);
    3. image=Qimage((const uchar*)cloneFrame->imageData,cloneFrame->width,cloneFrame->height,QImage::Format_RGB888),rgbSwapped();
    4. image = image.scaled(ui->original->size(),
    5. Qt::KeepAspectRatio,
    6. Qt::SmoothTransformation); // my QLabel size is (320,240)
    7.  
    8. qPainter = newQPainter(&image);
    9. qPainter -> begin(this);
    10. qPainter->setPen(QPen(Qt::red,1,Qt::SolidLine));
    11. qPainter->drawRect(0,0,319,239); //can't see the box since (319,239),
    12. qPainter->end();
    13. ui->original->setPixmap(qPixmap::fromImage(image));
    To copy to clipboard, switch view to plain text mode 

    I can't see my box out of (319,239)

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: pixel of Image display

    I guess thats why
    Qt Code:
    1. 1) qPainter = new QPainter(&image);
    2. 2) qPainter -> begin(this);
    To copy to clipboard, switch view to plain text mode 
    line 1) - painter will draw on image
    line 2) - now painter will draw on current widget, probably outside of paintEvent so you can't see the result

  5. The following user says thank you to stampede for this useful post:

    YDYD (17th July 2014)

Similar Threads

  1. QtQuick2 access image pixel
    By Talei in forum Qt Quick
    Replies: 4
    Last Post: 3rd June 2013, 09:02
  2. Replies: 2
    Last Post: 16th February 2012, 23:10
  3. Select pixel from image
    By sergio87 in forum Qt Programming
    Replies: 4
    Last Post: 2nd May 2011, 11:48
  4. Display GUI with pixel
    By arashadsaifi in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 19th January 2010, 21:23
  5. How do i display the rgb value of a pixel
    By davidw in forum Qt Programming
    Replies: 2
    Last Post: 17th May 2009, 23:51

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.