| 535 | #endif // DEAD_CODE |
| 536 | |
| 537 | void |
| 538 | Lut::to_float_packed(float* to, |
| 539 | const float* from, |
| 540 | const RectI & conversionRect, |
| 541 | const RectI & srcBounds, |
| 542 | const RectI & dstBounds, |
| 543 | PixelPackingEnum inputPacking, |
| 544 | PixelPackingEnum outputPacking, |
| 545 | bool invertY, |
| 546 | bool premult) const |
| 547 | { |
| 548 | ///clip the conversion rect to srcBounds and dstBounds |
| 549 | RectI rect = conversionRect; |
| 550 | |
| 551 | if ( !clip(&rect, srcBounds) || !clip(&rect, dstBounds) ) { |
| 552 | return; |
| 553 | } |
| 554 | |
| 555 | bool inputHasAlpha = inputPacking == ePixelPackingBGRA || inputPacking == ePixelPackingRGBA; |
| 556 | bool outputHasAlpha = outputPacking == ePixelPackingBGRA || outputPacking == ePixelPackingRGBA; |
| 557 | int inROffset, inGOffset, inBOffset, inAOffset; |
| 558 | int outROffset, outGOffset, outBOffset, outAOffset; |
| 559 | getOffsetsForPacking(inputPacking, &inROffset, &inGOffset, &inBOffset, &inAOffset); |
| 560 | getOffsetsForPacking(outputPacking, &outROffset, &outGOffset, &outBOffset, &outAOffset); |
| 561 | |
| 562 | int inPackingSize, outPackingSize; |
| 563 | inPackingSize = inputHasAlpha ? 4 : 3; |
| 564 | outPackingSize = outputHasAlpha ? 4 : 3; |
| 565 | |
| 566 | validate(); |
| 567 | |
| 568 | for (int y = rect.y1; y < rect.y2; ++y) { |
| 569 | int srcY = y; |
| 570 | if (invertY) { |
| 571 | srcY = srcBounds.y2 - y - 1; |
| 572 | } |
| 573 | |
| 574 | int dstY = dstBounds.y2 - y - 1; |
| 575 | const float *src_pixels = from + (srcY * (srcBounds.x2 - srcBounds.x1) * inPackingSize); |
| 576 | float *dst_pixels = to + (dstY * (dstBounds.x2 - dstBounds.x1) * outPackingSize); |
| 577 | /* go forwards from starting point to end of line: */ |
| 578 | for (int x = rect.x1; x < rect.x2; ++x) { |
| 579 | int inCol = x * inPackingSize; |
| 580 | int outCol = x * outPackingSize; |
| 581 | float a = (inputHasAlpha && premult) ? src_pixels[inCol + inAOffset] : 1.f;; |
| 582 | dst_pixels[outCol + outROffset] = toColorSpaceFloatFromLinearFloat(src_pixels[inCol + inROffset] * a); |
| 583 | dst_pixels[outCol + outGOffset] = toColorSpaceFloatFromLinearFloat(src_pixels[inCol + inGOffset] * a); |
| 584 | dst_pixels[outCol + outBOffset] = toColorSpaceFloatFromLinearFloat(src_pixels[inCol + inBOffset] * a); |
| 585 | if (outputHasAlpha) { |
| 586 | // alpha is linear and should not be dithered |
| 587 | dst_pixels[outCol + outAOffset] = a; |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | void |
| 594 | Lut::from_byte_planar(float* to, |
nothing calls this directly
no test coverage detected