From 925140af2adcf837185940fecb065908a94ee6c5 Mon Sep 17 00:00:00 2001 From: Javier Celaya Date: Mon, 9 Jun 2014 18:36:01 +0100 Subject: [PATCH] Keep v0.4.4 compatible with current state of RawTherapee - Subtract blacks from the output image to keep it compatible with the current state of RawTherapee. This won't work with every camera. --- DngFloatWriter.cpp | 41 ++++++----------------------------------- ImageIO.cpp | 2 +- ImageStack.cpp | 6 ++---- 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/DngFloatWriter.cpp b/DngFloatWriter.cpp index 1b08f0a..bb252d8 100644 --- a/DngFloatWriter.cpp +++ b/DngFloatWriter.cpp @@ -102,14 +102,9 @@ enum { void DngFloatWriter::write(Array2D && rawPixels, const RawParameters & p, const string & filename) { params = &p; rawData = std::move(rawPixels); - width = rawData.getWidth(); - height = rawData.getHeight(); - - // FIXME: This is temporal, until I fix RawTherapee width = params->width; height = params->height; rawData.displace(-(int)params->leftMargin, -(int)params->topMargin); - // FIXME: END renderPreviews(); @@ -235,38 +230,14 @@ void DngFloatWriter::createRawIFD() { // Areas uint32_t aa[4]; - aa[0] = params->topMargin; - aa[1] = params->leftMargin; - // FIXME: This is temporal, until I fix RawTherapee aa[0] = aa[1] = 0; - // FIXME: END - aa[2] = aa[0] + params->height; - aa[3] = aa[1] + params->width; + aa[2] = params->height; + aa[3] = params->width; rawIFD.addEntry(ACTIVEAREA, IFD::LONG, 4, aa); - uint32_t ma[16]; - int nma = 0; - if (aa[0] > 0) { - ma[nma] = 0; ma[nma + 1] = 0; ma[nma + 2] = aa[0]; ma[nma + 3] = width; nma += 4; - } - if (aa[1] > 0) { - ma[nma] = aa[0]; ma[nma + 1] = 0; ma[nma + 2] = aa[2]; ma[nma + 3] = aa[1]; nma += 4; - } - if (aa[2] < height) { - ma[nma] = aa[2]; ma[nma + 1] = 0; ma[nma + 2] = height; ma[nma + 3] = width; nma += 4; - } - if (aa[3] < width) { - ma[nma] = aa[0]; ma[nma + 1] = aa[3]; ma[nma + 2] = aa[2]; ma[nma + 3] = width; nma += 4; - } - if (nma > 0) { - rawIFD.addEntry(MASKEDAREAS, IFD::LONG, nma, ma); - } else { - // If there are no masked areas, black levels must be encoded, but not both. - uint16_t brep[2] = { 2, 2 }; - rawIFD.addEntry(BLACKLEVELREP, IFD::SHORT, 2, brep); - uint16_t cblack[] = { params->blackAt(0, 0), params->blackAt(1, 0), - params->blackAt(0, 1), params->blackAt(1, 1) }; - rawIFD.addEntry(BLACKLEVEL, IFD::SHORT, 4, cblack); - } + uint16_t brep[2] = { 2, 2 }; + rawIFD.addEntry(BLACKLEVELREP, IFD::SHORT, 2, brep); + uint16_t cblack[] = { 0, 0, 0, 0 }; + rawIFD.addEntry(BLACKLEVEL, IFD::SHORT, 4, cblack); uint32_t crop[2]; crop[0] = 0; crop[1] = 0; diff --git a/ImageIO.cpp b/ImageIO.cpp index 917ab81..0d0f16f 100644 --- a/ImageIO.cpp +++ b/ImageIO.cpp @@ -200,7 +200,7 @@ QImage ImageIO::renderPreview(const Array2D & rawData, const RawParameter for (size_t y = 0; y < params.rawHeight; ++y) { for (size_t x = 0; x < params.rawWidth; ++x) { size_t pos = y*params.rawWidth + x; - int v = (rawData[pos] - params.blackAt(x ^ oddx, y ^ oddy)) * scale; + int v = rawData[pos] * scale; if (v < 0) v = 0; else if (v > 65535) v = 65535; d.rawdata.raw_image[pos] = v; diff --git a/ImageStack.cpp b/ImageStack.cpp index 2121e2f..a536df3 100644 --- a/ImageStack.cpp +++ b/ImageStack.cpp @@ -164,12 +164,10 @@ Array2D ImageStack::compose(const RawParameters & params) const { } } dst.displace(params.leftMargin, params.topMargin); - // Scale to params.max and recover the black levels - size_t oddx = params.leftMargin & 1, oddy = params.topMargin + 1; + // Scale to params.max for (size_t y = 0; y < params.rawHeight; ++y) { for (size_t x = 0; x < params.rawWidth; ++x) { - dst(x, y) *= (params.max - params.maxBlack) / max; - dst(x, y) += params.blackAt(x ^ oddx, y ^ oddy); + dst(x, y) *= params.max / max; } }