]> Creatis software - clitk.git/blobdiff - vv/vvAnimatedGIFWriter.cxx
add include
[clitk.git] / vv / vvAnimatedGIFWriter.cxx
index 934d7dd24e80fa797755082ed0259e94903542b8..1efd50dcc1cc5f27be12899c980d41815be88587 100644 (file)
@@ -1,8 +1,6 @@
 #include "vvAnimatedGIFWriter.h"
 #include "clitkDD.h"
 
-#include "ximagif.h"
-
 #include <vtkImageData.h>
 #include <vtkImageQuantizeRGBToIndex.h>
 #include <vtkImageAppend.h>
@@ -10,6 +8,8 @@
 #include <vtkObjectFactory.h>
 #include <vtkLookupTable.h>
 
+#include "ximagif.h"
+
 //---------------------------------------------------------------------------
 vtkStandardNewMacro(vvAnimatedGIFWriter);
 
@@ -18,6 +18,7 @@ vvAnimatedGIFWriter::vvAnimatedGIFWriter()
 {
   Rate = 5;
   Loops = 0;
+  Dither = false;
 }
 
 //---------------------------------------------------------------------------
@@ -77,10 +78,18 @@ void vvAnimatedGIFWriter::End()
   std::vector<CxImage*> cximages( RGBslices.size() );
   for(unsigned int i=0; i<RGBslices.size(); i++) {
     cximages[i] = new CxImage;
-    cximages[i]->CreateFromArray((BYTE *)cast->GetOutput()->GetScalarPointer(0,0,i),
-                                 width, height, 8, width, false);
     cximages[i]->SetFrameDelay(100/Rate);
-    cximages[i]->SetPalette(pal);
+    if(Dither) {
+      cximages[i]->CreateFromArray((BYTE *)RGBvolume->GetOutput()->GetScalarPointer(0,0,i),
+                                   width, height, 24, width*3, false);
+      cximages[i]->SwapRGB2BGR();
+      cximages[i]->DecreaseBpp(8, true, pal);
+    }
+    else {
+      cximages[i]->CreateFromArray((BYTE *)cast->GetOutput()->GetScalarPointer(0,0,i),
+                                   width, height, 8, width, false);
+      cximages[i]->SetPalette(pal);
+    }
   }
 
   // Create gif