MCPcopy Create free account
hub / github.com/Kitware/VTK / ReplaceMaskColorWithBackgroundColor

Function ReplaceMaskColorWithBackgroundColor

Infovis/Core/vtkWordCloud.cxx:686–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

684 }
685}
686void ReplaceMaskColorWithBackgroundColor(vtkImageData* finalImage, vtkWordCloud* wordCloud)
687{
688 auto colors = vtkSmartPointer<vtkNamedColors>::New();
689
690 vtkColor3ub backgroundColor = colors->GetColor3ub(wordCloud->GetBackgroundColorName().c_str());
691 unsigned char bkgR = backgroundColor.GetData()[0];
692 unsigned char bkgG = backgroundColor.GetData()[1];
693 unsigned char bkgB = backgroundColor.GetData()[2];
694
695 vtkColor3ub maskColor = colors->GetColor3ub(wordCloud->GetMaskColorName().c_str());
696 unsigned char maskR = maskColor.GetData()[0];
697 unsigned char maskG = maskColor.GetData()[1];
698 unsigned char maskB = maskColor.GetData()[2];
699
700 vtkImageIterator<unsigned char> finalIt(finalImage, finalImage->GetExtent());
701 while (!finalIt.IsAtEnd())
702 {
703 auto finalSpan = finalIt.BeginSpan();
704 while (finalSpan != finalIt.EndSpan())
705 {
706 unsigned char R, G, B;
707 R = *finalSpan;
708 G = *(finalSpan + 1);
709 B = *(finalSpan + 2);
710 // If the pixel does not contain the background color, skip
711 // it. Otherwise replace it with the background color.
712 if (R != maskR && G != maskG && B != maskB)
713 {
714 finalSpan += 3;
715 continue;
716 }
717 else
718 {
719 *finalSpan = bkgR;
720 *(finalSpan + 1) = bkgG;
721 *(finalSpan + 2) = bkgB;
722 }
723 finalSpan += 3;
724 }
725 finalIt.NextSpan();
726 }
727}
728
729void ShowColorSeriesNames(ostream& os)
730{

Callers 1

RequestDataMethod · 0.85

Calls 7

GetColor3ubMethod · 0.80
NextSpanMethod · 0.80
NewFunction · 0.50
c_strMethod · 0.45
GetDataMethod · 0.45
GetExtentMethod · 0.45
IsAtEndMethod · 0.45

Tested by

no test coverage detected