Results 1 to 5 of 5

Thread: OpenEXR to QImage

  1. #1
    Join Date
    Feb 2014
    Posts
    23
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default OpenEXR to QImage

    Greetings,

    I've been pulling my hair trying to figure how to either enable QT to load exr/hdr images or simply to convert exr/hdr data to fit into a QImage. I'd definitely prefer the former but manual conversion would do just fine.

    thank you,
    Last edited by neosettler; 10th April 2019 at 05:31.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,249
    Thanks
    36
    Thanked 1,508 Times in 1,459 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: OpenEXR to QImage

    You need to find a library that provides a Qt Image Plugin for the format.

    A quick Google search got me these two
    https://github.com/AardmanCGI/qt4-exr-plugin
    https://api.kde.org/frameworks/kimag...tml/index.html

    Cheers,
    _

  3. #3
    Join Date
    Feb 2014
    Posts
    23
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: OpenEXR to QImage

    Tank you for your suggestion Anda, I should have mentioned that I'm using QT 5.12 on Windows 10.

    I've came across those two as well. The exr-plugin is for Qt4 and I doubt KDE could be compiled on Windows without pulling teeth. Plus, their documentation is clearly outdated so I'm a little hesitant to say the least.

  4. #4
    Join Date
    Feb 2014
    Posts
    23
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: OpenEXR to QImage

    Here is what I got so far:

    Qt Code:
    1. uint l_h = m_ZImage->GetHeight();
    2. uint l_w = m_ZImage->GetWidth();
    3. float *l_data = (float*)m_ZImage->GetPixels(); /// From uchar.
    4. m_QImage = QImage(l_w, l_h, QImage::Format_RGB888);
    5. uchar *l_pixels = m_QImage.bits();
    6.  
    7. for (uint i = 0; i < l_h; ++i)
    8. {
    9. for (uint j = 0; j < l_w; ++j)
    10. {
    11. uint l_id = (i * l_w) + j;
    12. l_pixels[l_id] = uchar(l_data[l_id] * 255); l_id++;
    13. l_pixels[l_id] = uchar(l_data[l_id] * 255); l_id++;
    14. l_pixels[l_id] = uchar(l_data[l_id] * 255);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    GetPixels() is from an EXR image loaded with FreeImage library (96-bit : 3 x 32-bit IEEE floating point). While the top third of the image is correct, the bottom 2/3 is black. I must be missing something very obvious!?

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,249
    Thanks
    36
    Thanked 1,508 Times in 1,459 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: OpenEXR to QImage

    Quote Originally Posted by neosettler View Post
    The exr-plugin is for Qt4
    Ah, I see.

    Still could be very similar code for Qt5, not sure if the image plugin API has changed at all.

    Quote Originally Posted by neosettler View Post
    I doubt KDE could be compiled on Windows without pulling teeth
    I don't see a reason why a library of Qt image plugins would be problematic on Windows.

    It is unlikely that libraries used by these plugins are not also available for Windows and cmake is usually quite capable of finding libs even on Windows.

    Quote Originally Posted by neosettler View Post
    While the top third of the image is correct, the bottom 2/3 is black. I must be missing something very obvious!?
    Strange.

    Maybe try a single loop? Both arrays should have the same number of elements.

    Cheers,
    _

Similar Threads

  1. QImage contains smaller QImage
    By Ini in forum General Programming
    Replies: 5
    Last Post: 31st May 2016, 17:11
  2. How to add new QImage to the left side of old QImage??
    By ganapathi in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2016, 08:54
  3. How to enable OpenEXR support in QT on windows
    By jho in forum Installation and Deployment
    Replies: 2
    Last Post: 9th March 2015, 11:18
  4. Replies: 5
    Last Post: 16th May 2011, 21:15
  5. Replies: 3
    Last Post: 15th March 2006, 11:44

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.