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

Method MagnifyImageNearest

Rendering/Parallel/vtkParallelRenderManager.cxx:1121–1240  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1119
1120//------------------------------------------------------------------------------
1121void vtkParallelRenderManager::MagnifyImageNearest(vtkUnsignedCharArray* fullImage,
1122 const int fullImageSize[2], vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
1123 const int fullImageViewport[4], const int reducedImageViewport[4])
1124{
1125 int numComp = reducedImage->GetNumberOfComponents();
1126
1127 fullImage->SetNumberOfComponents(4);
1128 fullImage->SetNumberOfTuples(fullImageSize[0] * fullImageSize[1]);
1129
1130 int destLeft, destBottom, destWidth, destHeight;
1131 if (fullImageViewport)
1132 {
1133 destLeft = fullImageViewport[0];
1134 destBottom = fullImageViewport[1];
1135 destWidth = fullImageViewport[2] - fullImageViewport[0];
1136 destHeight = fullImageViewport[3] - fullImageViewport[1];
1137 }
1138 else
1139 {
1140 destLeft = destBottom = 0;
1141 destWidth = fullImageSize[0];
1142 destHeight = fullImageSize[1];
1143 }
1144
1145 int srcLeft, srcBottom, srcWidth, srcHeight;
1146 if (reducedImageViewport)
1147 {
1148 srcLeft = reducedImageViewport[0];
1149 srcBottom = reducedImageViewport[1];
1150 srcWidth = reducedImageViewport[2] - reducedImageViewport[0];
1151 srcHeight = reducedImageViewport[3] - reducedImageViewport[1];
1152 }
1153 else
1154 {
1155 srcLeft = srcBottom = 0;
1156 srcWidth = reducedImageSize[0];
1157 srcHeight = reducedImageSize[1];
1158 }
1159
1160 if (numComp == 4)
1161 {
1162 // If there are 4 components per pixel, we can speed up the inflation
1163 // by copying integers instead of characters.
1164
1165 // Making a bunch of tmp variables for speed within the loops
1166 // Look I know the compiler should optimize this stuff
1167 // but I don't trust compilers... besides testing shows
1168 // this code is faster than the old code
1169 float xstep = (float)srcWidth / destWidth;
1170 float ystep = (float)srcHeight / destHeight;
1171 float xaccum = 0, yaccum = 0;
1172 int destlinesize = fullImageSize[0];
1173 int srclinesize = reducedImageSize[0];
1174 int xmemsize = 4 * destWidth;
1175 unsigned int* lastsrcline = nullptr;
1176 unsigned int* destline =
1177 (unsigned int*)fullImage->GetPointer(4 * (destBottom * destlinesize + destLeft));
1178 unsigned int* srcline =

Callers 1

MagnifyImageMethod · 0.95

Calls 4

GetNumberOfComponentsMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetPointerMethod · 0.45

Tested by

no test coverage detected