[opengtl-commits] [580] export to the highest input bit depth

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 580
Author:   cyrille
Date:     2009-03-02 12:54:30 +0100 (Mon, 02 Mar 2009)

Log Message:
-----------
export to the highest input bit depth

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp


Modified: trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2009-03-02 10:20:26 UTC (rev 579)
+++ trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2009-03-02 11:54:30 UTC (rev 580)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *  Copyright (c) 2008-2009 Cyrille Berger <cberger@xxxxxxxxxxx>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,6 +28,7 @@
 #include <GTLCore/Debug.h>
 #include <GTLCore/Region.h>
 #include <GTLCore/Type.h>
+#include <GTLCore/Macros_p.h>
 #include <GTLCore/Utils_p.h>
 
 // GTLImageIO Headers
@@ -126,6 +127,8 @@
     std::cerr << "Invalid command line parameters." << std::endl;
     printHelp();
   } else {
+    GTLCore::String errMsg;
+    // Load source code
     GTLCore::String source;
     std::ifstream in;
     in.open(fileName.c_str() );
@@ -141,24 +144,9 @@
       source += "\n";
       std::getline(in,str);
     }
-    int channelsCount = 3;
-    GTLCore::PixelDescription pixel( GTLCore::Type::UnsignedInteger8, channelsCount );
-    OpenShiva::Kernel p(channelsCount);
-    p.setSource( source );
-    p.compile();
-    GTLCore::String errMsg;
-    if(not p.isCompiled())
-    {
-      std::cerr << "Error: " << std::endl << p.compilationErrorsMessage() << std::endl;
-      while(true) {}
-      return EXIT_FAILURE;
-    }
-    
-    GTLCore::Region region(0,0,800,600);
-    if( p.hasGeneratedFunction() )
-    {
-      region = p.generated();
-    }
+    // Select the type of the resulting image
+    const GTLCore::Type* typeChannelImage = GTLCore::Type::UnsignedInteger8;
+    // Load Images
     std::list<GTLCore::AbstractImage*> images;
     std::list<GTLCore::Region> inputDOD;
     for( std::list< GTLCore::String >::iterator it = fileNames.begin();
@@ -178,7 +166,31 @@
       }
       images.push_back( image );
       inputDOD.push_back( region );
+      foreach( const GTLCore::Type* type, image->pixelDescription().channelTypes())
+      {
+        if( type->bitsSize() > typeChannelImage->bitsSize() )
+        {
+          typeChannelImage = type;
+        }
+      }
     }
+    int channelsCount = 3;
+    GTLCore::PixelDescription pixel( typeChannelImage, channelsCount );
+    OpenShiva::Kernel p(channelsCount);
+    p.setSource( source );
+    p.compile();
+    if(not p.isCompiled())
+    {
+      std::cerr << "Error: " << std::endl << p.compilationErrorsMessage() << std::endl;
+      while(true) {}
+      return EXIT_FAILURE;
+    }
+    
+    GTLCore::Region region(0,0,800,600);
+    if( p.hasGeneratedFunction() )
+    {
+      region = p.generated();
+    }
     if( p.hasChangedFunction() )
     {
       int i = 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/