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