MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / downscaleMipMap

Method downscaleMipMap

Engine/Image.cpp:2095–2132  ·  view source on GitHub ↗

code proofread and fixed by @devernay on 8/8/2014

Source from the content-addressed store, hash-verified

2093
2094// code proofread and fixed by @devernay on 8/8/2014
2095void
2096Image::downscaleMipMap(const RectD& dstRod,
2097 const RectI & roi,
2098 unsigned int fromLevel,
2099 unsigned int toLevel,
2100 bool copyBitMap,
2101 Image* output) const
2102{
2103 assert(getStorageMode() != eStorageModeGLTex);
2104
2105 ///You should not call this function with a level equal to 0.
2106 assert(toLevel > fromLevel);
2107
2108 assert(_bounds.x1 <= roi.x1 && roi.x2 <= _bounds.x2 &&
2109 _bounds.y1 <= roi.y1 && roi.y2 <= _bounds.y2);
2110 double par = getPixelAspectRatio();
2111// RectD roiCanonical;
2112// roi.toCanonical(fromLevel, par , dstRod, &roiCanonical);
2113// RectI dstRoI;
2114// roiCanonical.toPixelEnclosing(toLevel, par , &dstRoI);
2115 unsigned int downscaleLvls = toLevel - fromLevel;
2116
2117 assert( !copyBitMap || _bitmap.getBitmap() );
2118
2119 RectI dstRoI = roi.downscalePowerOfTwoSmallestEnclosing(downscaleLvls);
2120 ImagePtr tmpImg = std::make_shared<Image>( getComponents(), dstRod, dstRoI, toLevel, par, getBitDepth(), getPremultiplication(), getFieldingOrder(), true);
2121
2122 buildMipMapLevel( dstRod, roi, downscaleLvls, copyBitMap, tmpImg.get() );
2123
2124 // check that the downscaled mipmap is inside the output image (it may not be equal to it)
2125 assert(dstRoI.x1 >= output->_bounds.x1);
2126 assert(dstRoI.x2 <= output->_bounds.x2);
2127 assert(dstRoI.y1 >= output->_bounds.y1);
2128 assert(dstRoI.y2 <= output->_bounds.y2);
2129
2130 ///Now copy the result of tmpImg into the output image
2131 output->pasteFrom(*tmpImg, dstRoI, copyBitMap);
2132}
2133
2134bool
2135Image::checkForNaNsAndFix(const RectI& roi)

Callers 4

renderHandlerMethod · 0.80
renderSingleStrokeMethod · 0.80
renderRoIMethod · 0.80

Calls 6

getPixelAspectRatioFunction · 0.85
getBitDepthFunction · 0.85
getBitmapMethod · 0.80
pasteFromMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected