From ed41ccf46c1311c68d1cf4f0de95d17c07491af8 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 19 Apr 2012 14:37:54 +0200 Subject: [PATCH] Red and blue were swapped (different order between VTK and CxImage) --- vv/vvAnimatedGIFWriter.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vv/vvAnimatedGIFWriter.cxx b/vv/vvAnimatedGIFWriter.cxx index 75352ac..7af2ca4 100644 --- a/vv/vvAnimatedGIFWriter.cxx +++ b/vv/vvAnimatedGIFWriter.cxx @@ -75,11 +75,19 @@ void vvAnimatedGIFWriter::End() 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); } // Create gif FILE * pFile; pFile = fopen (this->FileName, "wb"); + if(pFile==NULL) { + vtkErrorMacro("Error in vvAnimatedGIFWriter::End: could not open " << this->FileName ); + return; + } CxImageGIF cximagegif; cximagegif.SetLoops(Loops); bool result = cximagegif.Encode(pFile,&(cximages[0]), (int)RGBslices.size(), true); -- 2.47.1