From: Simon Rit Date: Thu, 19 Apr 2012 12:37:54 +0000 (+0200) Subject: Red and blue were swapped (different order between VTK and CxImage) X-Git-Tag: v1.3.0~50^2^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ed41ccf46c1311c68d1cf4f0de95d17c07491af8;p=clitk.git Red and blue were swapped (different order between VTK and CxImage) --- 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);