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

Method RenderBackground

Rendering/FreeType/vtkFreeTypeTools.cxx:1685–1752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1683} // end namespace RasterScanQuad
1684
1685VTK_ABI_NAMESPACE_BEGIN
1686//------------------------------------------------------------------------------
1687void vtkFreeTypeTools::RenderBackground(
1688 vtkTextProperty* tprop, vtkImageData* image, ImageMetaData& metaData)
1689{
1690 unsigned char* color;
1691 unsigned char backgroundColor[4] = { static_cast<unsigned char>(
1692 tprop->GetBackgroundColor()[0] * 255),
1693 static_cast<unsigned char>(tprop->GetBackgroundColor()[1] * 255),
1694 static_cast<unsigned char>(tprop->GetBackgroundColor()[2] * 255),
1695 static_cast<unsigned char>(tprop->GetBackgroundOpacity() * 255) };
1696 unsigned char frameColor[4] = { static_cast<unsigned char>(tprop->GetFrameColor()[0] * 255),
1697 static_cast<unsigned char>(tprop->GetFrameColor()[1] * 255),
1698 static_cast<unsigned char>(tprop->GetFrameColor()[2] * 255),
1699 static_cast<unsigned char>(tprop->GetFrame() ? 255 : 0) };
1700
1701 if (backgroundColor[3] == 0 && frameColor[3] == 0)
1702 {
1703 return;
1704 }
1705
1706 const vtkVector2i& dx = metaData.dx;
1707 const vtkVector2i& dy = metaData.dy;
1708 const vtkVector2i& TL = metaData.TL;
1709 const vtkVector2i& TR = metaData.TR;
1710 const vtkVector2i& BL = metaData.BL;
1711 const vtkVector2i& BR = metaData.BR;
1712
1713 // Find the minimum and maximum y values:
1714 int yMin = std::min({ TL[1], TR[1], BL[1], BR[1] });
1715 int yMax = std::max({ TL[1], TR[1], BL[1], BR[1] });
1716
1717 // Clamp these to prevent out of bounds errors:
1718 int extent[6];
1719 image->GetExtent(extent);
1720 RasterScanQuad::clampToExtent(extent, 1, yMin);
1721 RasterScanQuad::clampToExtent(extent, 1, yMax);
1722
1723 // Scan from yMin to yMax, finding the x values on that horizontal line that
1724 // are contained by the data rectangle, then paint them with the background
1725 // color.
1726 int frameWidth = tprop->GetFrameWidth();
1727 for (int y = yMin; y <= yMax; ++y)
1728 {
1729 int xMin, xMax;
1730 if (RasterScanQuad::findScanRange(TL, TR, BL, BR, dx, dy, y, xMin, xMax))
1731 {
1732 // Clamp to prevent out of bounds errors:
1733 RasterScanQuad::clampToExtent(extent, 0, xMin);
1734 RasterScanQuad::clampToExtent(extent, 0, xMax);
1735
1736 // Get a pointer into the image data:
1737 unsigned char* dataPtr = static_cast<unsigned char*>(image->GetScalarPointer(xMin, y, 0));
1738 for (int x = xMin; x <= xMax; ++x)
1739 {
1740 color = (frameColor[3] != 0 &&
1741 (y < (yMin + frameWidth) || y > (yMax - frameWidth) || x < (xMin + frameWidth) ||
1742 x > (xMax - frameWidth)))

Callers 1

RenderStringInternalMethod · 0.95

Calls 7

clampToExtentFunction · 0.85
findScanRangeFunction · 0.85
GetScalarPointerMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
GetBackgroundColorMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected