From: Simon Rit Date: Thu, 19 Apr 2012 16:20:10 +0000 (+0200) Subject: First githering option for animated gif using CxImage option X-Git-Tag: v1.3.0~48^2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b2fe358ebe93931cd09fbadfc60bb34ec8e25090;p=clitk.git First githering option for animated gif using CxImage option --- diff --git a/vv/vvAnimatedGIFWriter.cxx b/vv/vvAnimatedGIFWriter.cxx index 934d7dd..8ba0f69 100644 --- a/vv/vvAnimatedGIFWriter.cxx +++ b/vv/vvAnimatedGIFWriter.cxx @@ -18,6 +18,7 @@ vvAnimatedGIFWriter::vvAnimatedGIFWriter() { Rate = 5; Loops = 0; + Dither = false; } //--------------------------------------------------------------------------- @@ -77,10 +78,18 @@ void vvAnimatedGIFWriter::End() std::vector cximages( RGBslices.size() ); for(unsigned int i=0; iCreateFromArray((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 diff --git a/vv/vvAnimatedGIFWriter.h b/vv/vvAnimatedGIFWriter.h index 8242779..2fde827 100644 --- a/vv/vvAnimatedGIFWriter.h +++ b/vv/vvAnimatedGIFWriter.h @@ -32,12 +32,18 @@ public: vtkSetClampMacro(Loops, int, 0, 5000); vtkGetMacro(Loops, int); + // Description: + // Set/Get the dithering + vtkSetMacro(Dither, bool); + vtkGetMacro(Dither, bool); + protected: vvAnimatedGIFWriter(); ~vvAnimatedGIFWriter(); int Rate; int Loops; + bool Dither; vtkSmartPointer RGBvolume; std::vector< vtkSmartPointer > RGBslices; diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index c08462c..46b0ecb 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -2822,6 +2822,13 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget) tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok); if(ok) gif->SetLoops(loops); + + // Dithering + QString msg = "Would you like to activate dithering?"; + QMessageBox msgBox(QMessageBox::Question, tr("Dithering"),msg, 0, this); + msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole); + msgBox.addButton(tr("No"), QMessageBox::RejectRole); + gif->SetDither(msgBox.exec() == QMessageBox::AcceptRole); } #endif #ifdef VTK_USE_VIDEO_FOR_WINDOWS