{
Rate = 5;
Loops = 0;
+ Dither = false;
}
//---------------------------------------------------------------------------
cast->SetOutputScalarTypeToUnsignedChar();
cast->Update();
+ // Create palette for CxImage => Swap r and b in LUT
+ RGBQUAD pal[256];
+ memcpy(pal, (RGBQUAD*)(quant->GetLookupTable()->GetPointer(0)), sizeof(RGBQUAD)*256);
+ for(unsigned int j=0; j<256; j++)
+ std::swap(pal[j].rgbBlue, pal[j].rgbRed);
+
// Create a stack of CxImages
DWORD width = cast->GetOutput()->GetExtent()[1]-cast->GetOutput()->GetExtent()[0]+1;
DWORD height = cast->GetOutput()->GetExtent()[3]-cast->GetOutput()->GetExtent()[2]+1;
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((RGBQUAD*)(quant->GetLookupTable()->GetPointer(0)));
- // Swap r and b in LUT before setting it
- RGBQUAD *pal = cximages[i]->GetPalette();
- for(unsigned int j=0; j<256; j++)
- std::swap(pal[j].rgbBlue, pal[j].rgbRed);
+ 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
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<vtkImageAppend> RGBvolume;
std::vector< vtkSmartPointer<vtkImageData> > RGBslices;
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