Results 1 to 4 of 4

Thread: How to convert EImage into QImage and show it in a QWidget?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: How to convert EImage into QImage and show it in a QWidget?

    Thank you anda_skoa,

    I used your first advice and it's working.

    store the image and call update() and draw in paintEvent
    So this is my new code.
    Qt Code:
    1. void MainWindow::paintEvent(QPaintEvent *)
    2. {
    3. QPainter painter(this);
    4. painter.drawImage(QPoint(0,0),currentImage);
    5. }
    6.  
    7. void MainWindow::ProcessingCallback(Channel &Ch, SignalInfo &Info)
    8. {
    9. try
    10. {
    11. // Update the eVision image with the acquired image data
    12. UpdateImageConfig(*Info.Surf, EImgSrc);
    13.  
    14. // Inversion between the first and the third color component of each pixel component (EImage is BGR coded)
    15. for(INT32 x=0; x<EImgSrc.GetWidth(); x++)
    16. {
    17. for(INT32 y=0; y<EImgSrc.GetHeight(); y++)
    18. {
    19. EC24 pixE = EImgSrc.GetPixel(x, y);
    20. UINT8 temp = pixE.m_un8C2;
    21. pixE.m_un8C2 = pixE.m_un8C0;
    22. pixE.m_un8C0 = temp;
    23. EImgSrc.SetPixel(pixE, x, y);
    24. }
    25. }
    26.  
    27. // Convert EImage to QImage
    28. QImage newImage((const uchar*)EImgSrc.GetGenericImagePtr(), EImgSrc.GetWidth(), EImgSrc.GetHeight(), QImage::Format_RGB888);
    29.  
    30. // Display the new image
    31. currentImage = newImage;
    32. this->update();
    33.  
    34. }
    35. catch (Euresys::MultiCam::Exception &e)
    36. {
    37. // Display the exceptions...
    38. }
    39. }
    To copy to clipboard, switch view to plain text mode 
    With
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. #include "EasyMultiCam.h"
    7.  
    8. using namespace Euresys::MultiCam;
    9. using namespace Euresys::eVision::EasyMultiCam;
    10.  
    11. class MainWindow : public QMainWindow
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. MainWindow();
    17. EImageC24 EImgSrc;
    18. QImage currentImage;
    19. // ...
    20.  
    21. public slots:
    22. void ProcessingCallback(Channel &Ch, SignalInfo &Info);
    23. // ...
    24.  
    25. private slots:
    26. void paintEvent(QPaintEvent *);
    27. // ...
    28.  
    29. };
    30.  
    31. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    Thank you again for the efficiency of your advices.

    Bye!
    Last edited by FloFox; 15th February 2013 at 14:30.

Similar Threads

  1. IPC- char * to WCHAR* convertion?
    By Ricardo_arg in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2010, 18:55
  2. Text file to PDF convertion using C++ code
    By joseph in forum General Discussion
    Replies: 2
    Last Post: 21st August 2008, 01:28
  3. Convertion between QLineEdit formated to Double
    By vcp in forum Qt Programming
    Replies: 4
    Last Post: 13th June 2008, 17:15
  4. Time convertion
    By rajeshs in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2008, 11:22

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