Hello,
I'm back here with EXR compression support. First, I'd like to note
that I don't think it would be good to apply it before 0.8 is out.
This is ONLY PREVIEW, see known problems.

Also I'd like to ask what should I change to get that list for
selecting compression correctly aligned. Because I don't know
wxWidgets I've copied tiff related part from xrc file and changed it,
but it not aligned on the right of output format selector but in new
line.

Known problems:
-------------------------
* compression is not yet forwarded to makefile
* problem with alignment of controls in GUI (see question above)
* it's almost untested
* will ever anyone use it?
* showing B44(A) compression only for OpenEXR 1.6 is not yet done

Regards,
Lukáš "stativ" Jirkovský

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to hugin-ptx@googlegroups.com
To unsubscribe from this group, send email to 
hugin-ptx-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---

Index: src/foreign/vigra/vigra_impex/exr.cxx
===================================================================
--- src/foreign/vigra/vigra_impex/exr.cxx	(revision 3649)
+++ src/foreign/vigra/vigra_impex/exr.cxx	(working copy)
@@ -447,6 +447,7 @@
     {
         VIGRA_IMPEX_FINALIZED(pimpl->finalized);
         pimpl->setCompressionType(comp, quality);
+        //std::cout << "Setting compression " << comp << ", quality " << quality << std::endl;
     }
 
     void ExrEncoder::setPosition( const Diff2D & pos )
Index: src/hugin1/hugin/xrc/pano_panel.xrc
===================================================================
--- src/hugin1/hugin/xrc/pano_panel.xrc	(revision 3649)
+++ src/hugin1/hugin/xrc/pano_panel.xrc	(working copy)
@@ -881,6 +881,36 @@
                                       <flag>wxLEFT</flag>
                                       <border>3</border>
                                     </object>
+                                    <object class="sizeritem">
+                                      <object class="wxPanel" name="pano_output_hdr_opts_exr">
+                                        <object class="wxBoxSizer">
+                                          <orient>wxHORIZONTAL</orient>
+                                          <object class="sizeritem">
+                                            <object class="wxStaticText">
+                                              <label>Compression:</label>
+                                            </object>
+                                            <flag>wxALIGN_CENTRE_VERTICAL</flag>
+                                          </object>
+                                          <object class="sizeritem">
+                                            <object class="wxChoice" name="pano_output_hdr_opts_exr_compression">
+                                              <content>
+                                                <item>PIZ</item>
+                                                <item>ZIP</item>
+                                                <item>RLE</item>
+                                                <item>PXR24 (lossy)</item>
+                                                <item>B44 (lossy)</item>
+                                                <item>B44A (lossy)</item>
+                                                <item>NONE</item>
+                                              </content>
+                                            </object>
+                                            <flag>wxLEFT|wxALL|wxALIGN_CENTRE_VERTICAL</flag>
+                                            <border>6</border>
+                                          </object>
+                                        </object>
+                                      </object>
+                                      <flag>wxLEFT</flag>
+                                      <border>3</border>
+                                    </object>
                                   </object>
                                 </object>
                               </object>
@@ -1016,4 +1046,4 @@
       </object>
     </object>
   </object>
-</resource>
\ No newline at end of file
+</resource>
Index: src/hugin1/hugin/PanoPanel.h
===================================================================
--- src/hugin1/hugin/PanoPanel.h	(revision 3649)
+++ src/hugin1/hugin/PanoPanel.h	(working copy)
@@ -128,6 +128,7 @@
     void OnJPEGQualityText(wxCommandEvent & e);
     void OnNormalTIFFCompression(wxCommandEvent & e);
     void OnHDRTIFFCompression(wxCommandEvent & e);
+    void OnHDREXRCompression(wxCommandEvent & e);
 
     void OnHDRFileFormatOpts(wxCommandEvent & e);
 
@@ -191,6 +192,8 @@
     wxChoice    * m_HDRFileFormatChoice;
     wxPanel     * m_HDRFileFormatPanelTIFF;
     wxChoice    * m_FileFormatHDRTIFFCompChoice;
+    wxPanel     * m_HDRFileFormatPanelEXR;
+    wxChoice    * m_FileFormatHDREXRCompChoice;
 
     wxScrolledWindow *m_pano_ctrls;
 
Index: src/hugin1/hugin/PanoPanel.cpp
===================================================================
--- src/hugin1/hugin/PanoPanel.cpp	(revision 3649)
+++ src/hugin1/hugin/PanoPanel.cpp	(working copy)
@@ -113,6 +113,7 @@
     EVT_TEXT_ENTER ( XRCID("pano_output_normal_opts_jpeg_quality"),PanoPanel::OnJPEGQualityText )
     EVT_CHOICE ( XRCID("pano_output_normal_opts_tiff_compression"),PanoPanel::OnNormalTIFFCompression)
     EVT_CHOICE ( XRCID("pano_output_hdr_opts_tiff_compression"),PanoPanel::OnHDRTIFFCompression)
+    EVT_CHOICE ( XRCID("pano_output_hdr_opts_exr_compression"),PanoPanel::OnHDREXRCompression)
 
 END_EVENT_TABLE()
 
@@ -261,6 +262,11 @@
     m_FileFormatHDRTIFFCompChoice = XRCCTRL(*this, "pano_output_hdr_opts_tiff_compression", wxChoice);
     DEBUG_ASSERT(m_FileFormatHDRTIFFCompChoice);
 
+    m_HDRFileFormatPanelEXR = XRCCTRL(*this, "pano_output_hdr_opts_exr", wxPanel);
+    DEBUG_ASSERT(m_HDRFileFormatPanelEXR);
+    m_FileFormatHDREXRCompChoice = XRCCTRL(*this, "pano_output_hdr_opts_exr_compression", wxChoice);
+    DEBUG_ASSERT(m_FileFormatHDREXRCompChoice);
+
     m_pano_ctrls = XRCCTRL(*this, "pano_controls_panel", wxScrolledWindow);
     DEBUG_ASSERT(m_pano_ctrls);
     m_pano_ctrls->SetSizeHints(20, 20);
@@ -526,9 +532,24 @@
     i=0;
     if (opt.outputImageTypeHDR == "exr") {
         i = 0;
+        m_HDRFileFormatPanelEXR->Show();
         m_HDRFileFormatPanelTIFF->Hide();
+        if (opt.outputImageTypeHDRCompression  == "ZIP") {
+           m_FileFormatHDREXRCompChoice->SetSelection(1);
+        } else if (opt.outputImageTypeHDRCompression == "RLE") {
+           m_FileFormatHDREXRCompChoice->SetSelection(2);
+        } else if (opt.outputImageTypeHDRCompression == "PXR24") {
+           m_FileFormatHDREXRCompChoice->SetSelection(3);
+        } else if (opt.outputImageTypeHDRCompression == "B44") {
+           m_FileFormatHDREXRCompChoice->SetSelection(4);
+        } else if (opt.outputImageTypeHDRCompression == "B44A") {
+           m_FileFormatHDREXRCompChoice->SetSelection(5);
+        } else {
+           m_FileFormatHDREXRCompChoice->SetSelection(0);
+        }
     } else if (opt.outputImageTypeHDR == "tif") {
         i = 1;
+        m_HDRFileFormatPanelEXR->Hide();
         m_HDRFileFormatPanelTIFF->Show();
         if (opt.outputImageTypeHDRCompression  == "PACKBITS") {
             m_FileFormatHDRTIFFCompChoice->SetSelection(1);
@@ -1095,11 +1116,13 @@
     PanoramaOptions opt = pano->getOptions();
     switch (fmt) {
         case 1:
+            m_HDRFileFormatPanelEXR->Hide();
             m_HDRFileFormatPanelTIFF->Show();
             opt.outputImageTypeHDR ="tif";
             break;
         default:
         case 0:
+            m_HDRFileFormatPanelEXR->Show();
             m_HDRFileFormatPanelTIFF->Hide();
             opt.outputImageTypeHDR ="exr";
             break;
@@ -1154,6 +1177,38 @@
             );
 }
 
+void PanoPanel::OnHDREXRCompression(wxCommandEvent & e)
+{
+    PanoramaOptions opt = pano->getOptions();
+    switch(e.GetSelection()) {
+        case 0:
+        default:
+            opt.outputImageTypeHDRCompression = "PIZ";
+            break;
+        case 1:
+            opt.outputImageTypeHDRCompression = "ZIP";
+            break;
+        case 2:
+            opt.outputImageTypeHDRCompression = "RLE";
+            break;
+        case 3:
+            opt.outputImageTypeHDRCompression = "PXR24";
+            break;
+        case 4:
+           opt.outputImageTypeHDRCompression = "B44";
+           break;
+        case 5:
+           opt.outputImageTypeHDRCompression = "B44A";
+           break;
+        case 6:
+           opt.outputImageTypeHDRCompression = "NONE";
+           break;
+    }
+    GlobalCmdHist::getInstance().addCommand(
+            new PT::SetPanoOptionsCmd( *pano, opt )
+            );
+}
+
 void PanoPanel::OnHDRTIFFCompression(wxCommandEvent & e)
 {
     PanoramaOptions opt = pano->getOptions();
Index: src/hugin1/hugin/NonaStitcherPanel.cpp
===================================================================
--- src/hugin1/hugin/NonaStitcherPanel.cpp	(revision 3649)
+++ src/hugin1/hugin/NonaStitcherPanel.cpp	(working copy)
@@ -188,6 +188,27 @@
           } else {
               DEBUG_ERROR("Unknown compression type");
           }
+      } else if (opt.outputFormat == PanoramaOptions::EXR ||
+          opt.outputFormat == PanoramaOptions::EXR_m)
+      {
+          m_CompTypeChoice->Enable();
+          if (opt.exrCompression == "PIZ") {
+              m_CompTypeChoice->SetSelection(0);
+          } else if (opt.tiffCompression == "ZIP") {
+              m_CompTypeChoice->SetSelection(1);
+          } else if (opt.tiffCompression == "RLE") {
+              m_CompTypeChoice->SetSelection(2);
+          } else if (opt.tiffCompression == "PXR24") {
+              m_CompTypeChoice->SetSelection(3);
+          } else if (opt.tiffCompression == "B44") {
+              m_CompTypeChoice->SetSelection(4);
+          } else if (opt.tiffCompression == "B44A") {
+              m_CompTypeChoice->SetSelection(5);
+          } else if (opt.tiffCompression == "NONE") {
+              m_CompTypeChoice->SetSelection(6);
+          } else {
+              DEBUG_ERROR("Unknown compression type");
+          }
       } else {
           m_CompTypeChoice->Disable();
       }
@@ -470,7 +491,7 @@
 void NonaStitcherPanel::OnCompTypeChanged( wxCommandEvent & e )
 {
     PanoramaOptions opt = pano.getOptions();
-
+// TODO: there should be probably handled also exr compression
     switch (e.GetSelection()) {
         case 0:
             opt.tiffCompression = "NONE";
Index: src/tools/nona.cpp
===================================================================
--- src/tools/nona.cpp	(revision 3649)
+++ src/tools/nona.cpp	(working copy)
@@ -223,7 +223,10 @@
     PanoramaOptions  opts = pano.getOptions();
 
     if (compression.size() > 0) {
-        opts.tiffCompression=compression;
+        if ((outputFormat == "TIFF_m") || (outputFormat == "TIFF") || (outputFormat == "TIFF_multilayer"))
+            opts.tiffCompression=compression;
+        else if ((outputFormat == "EXR_m") || (outputFormat == "EXR"))
+            opts.exrCompression=compression;
     }
 
     // save coordinate images, if requested
Index: src/hugin_base/panodata/Panorama.cpp
===================================================================
--- src/hugin_base/panodata/Panorama.cpp	(revision 3649)
+++ src/hugin_base/panodata/Panorama.cpp	(working copy)
@@ -1828,9 +1828,27 @@
                             }
                         }
                     }
-                break;
-                default:
-                break;
+                    break;
+                    case PanoramaOptions::EXR:
+                    case PanoramaOptions::EXR_m:
+                    {
+                       // parse exr compression mode
+                       std::string comp;
+                           if (getPTParam(comp, format, "c:")) {
+                               if (comp == "PIZ" || comp == "ZIP" ||
+                                   comp == "RLE" || comp == "PXR24" ||
+                                   comp == "B44" || comp == "B44A" ||
+                                   comp == "NONE")
+                               {
+                                   options.exrCompression = comp;
+                               } else {
+                                   DEBUG_WARN("No valid exr compression found");
+                               }
+                           }
+                    }
+                    break;
+                    default:
+                    break;
                 }
             }
 
Index: src/hugin_base/panodata/PanoramaOptions.cpp
===================================================================
--- src/hugin_base/panodata/PanoramaOptions.cpp	(revision 3649)
+++ src/hugin_base/panodata/PanoramaOptions.cpp	(working copy)
@@ -122,6 +122,10 @@
         if (tiff_saveROI) {
             o << " r:CROP";
         }
+    } else if ( outputFormat == EXR ||
+                outputFormat == EXR_m)
+    {
+        o << " c:" << exrCompression;
     }
     o << "\"";
     o << std::endl;
Index: src/hugin_base/panodata/PanoramaOptions.h
===================================================================
--- src/hugin_base/panodata/PanoramaOptions.h	(revision 3649)
+++ src/hugin_base/panodata/PanoramaOptions.h	(working copy)
@@ -204,6 +204,9 @@
             outfile = "panorama";
             tiff_saveROI = true;
             tiffCompression = "NONE";
+#ifdef HasEXR
+            exrCompression = "PIZ";
+#endif
             quality = 100;
             colorCorrection = NONE;
             colorReferenceImage = 0;
@@ -351,6 +354,9 @@
         std::string tiffCompression;
         bool tiff_saveROI;
 
+        // EXR options
+        std::string exrCompression;
+
         ColorCorrection colorCorrection;
         unsigned int colorReferenceImage;
 
Index: src/hugin_base/nona/Stitcher.h
===================================================================
--- src/hugin_base/nona/Stitcher.h	(revision 3649)
+++ src/hugin_base/nona/Stitcher.h	(working copy)
@@ -351,6 +351,9 @@
         if (ext == "tif") {
             exinfo.setCompression(opts.tiffCompression.c_str());
         }
+        if (ext == "exr") {
+            exinfo.setCompression(opts.exrCompression.c_str());
+        }
 
         vigra::exportImageAlpha(srcImageRange(*final_img), srcImage(*alpha_img),
                                     exinfo);
@@ -610,6 +613,10 @@
         } else if (opts.outputFormat == PanoramaOptions::HDR) {
             exinfo.setPixelType("FLOAT");
             vigra::exportImage(srcImageRange(pano), exinfo);
+        } else if (opts.outputFormat == PanoramaOptions::EXR) {
+            exinfo.setCompression(opts.exrCompression.c_str());
+            vigra::exportImageAlpha(srcImageRange(pano),
+                                           srcImage(panoMask), exinfo);
         } else {
             vigra::exportImageAlpha(srcImageRange(pano),
                                            srcImage(panoMask), exinfo);
@@ -744,6 +751,10 @@
                                     srcImage(panoMask), exinfo);
         } else if (opts.outputFormat == PanoramaOptions::HDR) {
             vigra::exportImage(srcImageRange(pano), exinfo);
+        } else if (opts.outputFormat == PanoramaOptions::EXR) {
+            exinfo.setCompression(opts.exrCompression.c_str());
+            vigra::exportImageAlpha(srcImageRange(pano),
+                                    srcImage(panoMask), exinfo);
         } else {
             vigra::exportImageAlpha(srcImageRange(pano),
                                     srcImage(panoMask), exinfo);

Reply via email to