MCPcopy Create free account
hub / github.com/darktable-org/rawspeed / decodeMaskedAreas

Method decodeMaskedAreas

src/librawspeed/decoders/DngDecoder.cpp:637–675  ·  view source on GitHub ↗

Decodes DNG masked areas into blackareas in the image */

Source from the content-addressed store, hash-verified

635
636/* Decodes DNG masked areas into blackareas in the image */
637bool DngDecoder::decodeMaskedAreas(const TiffIFD* raw) {
638 TiffEntry *masked = raw->getEntry(MASKEDAREAS);
639
640 if (masked->type != TIFF_SHORT && masked->type != TIFF_LONG)
641 return false;
642
643 uint32_t nrects = masked->count / 4;
644 if (0 == nrects)
645 return false;
646
647 /* Since we may both have short or int, copy it to int array. */
648 auto rects = masked->getU32Array(nrects*4);
649
650 const iRectangle2D fullImage(0, 0, mRaw->getUncroppedDim().x,
651 mRaw->getUncroppedDim().y);
652 const iPoint2D top = mRaw->getCropOffset();
653
654 for (uint32_t i = 0; i < nrects; i++) {
655 iPoint2D topleft = iPoint2D(rects[i * 4UL + 1UL], rects[i * 4UL]);
656 iPoint2D bottomright = iPoint2D(rects[i * 4UL + 3UL], rects[i * 4UL + 2UL]);
657
658 if (!(fullImage.isPointInsideInclusive(topleft) &&
659 fullImage.isPointInsideInclusive(bottomright) &&
660 (topleft < bottomright)))
661 ThrowRDE("Bad masked area.");
662
663 // Is this a horizontal box, only add it if it covers the active width of the image
664 if (topleft.x <= top.x && bottomright.x >= (mRaw->dim.x + top.x)) {
665 mRaw->blackAreas.emplace_back(topleft.y, bottomright.y - topleft.y,
666 false);
667 }
668 // Is it a vertical box, only add it if it covers the active height of the
669 // image
670 else if (topleft.y <= top.y && bottomright.y >= (mRaw->dim.y + top.y)) {
671 mRaw->blackAreas.emplace_back(topleft.x, bottomright.x - topleft.x, true);
672 }
673 }
674 return !mRaw->blackAreas.empty();
675}
676
677bool DngDecoder::decodeBlackLevels(const TiffIFD* raw) {
678 iPoint2D blackdim(1,1);

Callers

nothing calls this directly

Calls 7

getU32ArrayMethod · 0.80
getUncroppedDimMethod · 0.80
getCropOffsetMethod · 0.80
emptyMethod · 0.80
iPoint2DClass · 0.70
getEntryMethod · 0.45

Tested by

no test coverage detected