RawTherapee icon indicating copy to clipboard operation
RawTherapee copied to clipboard

Fix regression with demosaiced DNGs caused by 831a9bbd

Open Entropy512 opened this issue 11 months ago • 2 comments

Demosaiced DNGs (aka LinearRAW PhotometricInterpretation) have 3 samples per pixel, so rawData.getWidth() returns triple the width Only throw an assert if getWidth is not a multiple of W. This new implementation assumes that getWidth() will never be zero when getHeight() is nonzero

Fixes #6996

Entropy512 avatar Mar 17 '24 13:03 Entropy512

It's probably best to refactor these checks (including the first if-statement in getRawValues) to use a function that checks the validity of the dimensions.

bool checkRawDataDimensions(const array2D<float> &rawData, const RawImage &rawImage, int width, int height)
{
    const int colors = (rawImage.getSensorType() == ST_BAYER ||
                           rawImage.getSensorType() == ST_FUJI_XTRANS ||
                           rawImage.get_colors() == 1)
                           ? 1
                           : 3;
    return rawData.getHeight() == height && rawData.getWidth() == colors * width;
}

Lawrence37 avatar Mar 17 '24 18:03 Lawrence37

Great! Thanks for the suggestions including where to get the equivalent of SamplesPerPixel. I've had a few too many Tasty Beverages for tonight, I'll work on this refactor tomorrow.

Entropy512 avatar Mar 17 '24 22:03 Entropy512