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

Method convertToFormatInternalForColorSpace

Engine/ImageConvert.cpp:241–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239template <typename SRCPIX, typename DSTPIX, int srcMaxValue, int dstMaxValue, int srcNComps, int dstNComps,
240 bool requiresUnpremult, bool useColorspaces>
241void
242Image::convertToFormatInternalForColorSpace(const RectI & renderWindow,
243 const Image & srcImg,
244 Image & dstImg,
245 bool copyBitmap,
246 bool useAlpha0,
247 ViewerColorSpaceEnum srcColorSpace,
248 ViewerColorSpaceEnum dstColorSpace,
249 int channelForAlpha)
250{
251 /*
252 * If channelForAlpha is -1 the user wants to convert using the default
253 * If channelForAlpha >= 0 then the user wants a specific channel to convert from. This is used mainly when converting
254 * to Alpha images (masks) to know which channel to use for the mask.
255 */
256 if (channelForAlpha != -1) {
257 switch (srcNComps) {
258 case 3:
259 //invalid value passed by the called
260 if (channelForAlpha > 2) {
261 channelForAlpha = -1;
262 }
263 break;
264 case 2:
265 //invalid value passed by the called
266 if (channelForAlpha > 1) {
267 channelForAlpha = -1;
268 }
269 default:
270 break;
271 }
272 } else {
273 switch (srcNComps) {
274 case 4:
275 channelForAlpha = 3;
276 break;
277 case 3:
278 case 1:
279 default:
280 //no alpha anyway
281 break;
282 }
283 }
284
285
286 ///special case comp == alpha && channelForAlpha = -1 clear out the mask
287 if ( (dstNComps == 1) && (channelForAlpha == -1) ) {
288 DSTPIX* dstPixels = (DSTPIX*)dstImg.pixelAt(renderWindow.x1, renderWindow.y1);
289 int dstRowSize = dstImg._bounds.width() * dstNComps;
290 if (copyBitmap) {
291 dstImg.copyBitmapPortion(renderWindow, srcImg);
292 }
293 for (int y = 0; y < renderWindow.height();
294 ++y, dstPixels += dstRowSize) {
295 std::fill(dstPixels, dstPixels + renderWindow.width() * dstNComps, 0.);
296 }
297
298 return;

Callers

nothing calls this directly

Calls 13

lutFromColorspaceFunction · 0.85
isnanFunction · 0.85
copyBitmapPortionMethod · 0.80
fillFunction · 0.50
pixelAtMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected