Skip to content

Commit 925140a

Browse files
committed
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.
1 parent 9261b6a commit 925140a

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

DngFloatWriter.cpp

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,9 @@ enum {
102102
void DngFloatWriter::write(Array2D<float> && rawPixels, const RawParameters & p, const string & filename) {
103103
params = &p;
104104
rawData = std::move(rawPixels);
105-
width = rawData.getWidth();
106-
height = rawData.getHeight();
107-
108-
// FIXME: This is temporal, until I fix RawTherapee
109105
width = params->width;
110106
height = params->height;
111107
rawData.displace(-(int)params->leftMargin, -(int)params->topMargin);
112-
// FIXME: END
113108

114109
renderPreviews();
115110

@@ -235,38 +230,14 @@ void DngFloatWriter::createRawIFD() {
235230

236231
// Areas
237232
uint32_t aa[4];
238-
aa[0] = params->topMargin;
239-
aa[1] = params->leftMargin;
240-
// FIXME: This is temporal, until I fix RawTherapee
241233
aa[0] = aa[1] = 0;
242-
// FIXME: END
243-
aa[2] = aa[0] + params->height;
244-
aa[3] = aa[1] + params->width;
234+
aa[2] = params->height;
235+
aa[3] = params->width;
245236
rawIFD.addEntry(ACTIVEAREA, IFD::LONG, 4, aa);
246-
uint32_t ma[16];
247-
int nma = 0;
248-
if (aa[0] > 0) {
249-
ma[nma] = 0; ma[nma + 1] = 0; ma[nma + 2] = aa[0]; ma[nma + 3] = width; nma += 4;
250-
}
251-
if (aa[1] > 0) {
252-
ma[nma] = aa[0]; ma[nma + 1] = 0; ma[nma + 2] = aa[2]; ma[nma + 3] = aa[1]; nma += 4;
253-
}
254-
if (aa[2] < height) {
255-
ma[nma] = aa[2]; ma[nma + 1] = 0; ma[nma + 2] = height; ma[nma + 3] = width; nma += 4;
256-
}
257-
if (aa[3] < width) {
258-
ma[nma] = aa[0]; ma[nma + 1] = aa[3]; ma[nma + 2] = aa[2]; ma[nma + 3] = width; nma += 4;
259-
}
260-
if (nma > 0) {
261-
rawIFD.addEntry(MASKEDAREAS, IFD::LONG, nma, ma);
262-
} else {
263-
// If there are no masked areas, black levels must be encoded, but not both.
264-
uint16_t brep[2] = { 2, 2 };
265-
rawIFD.addEntry(BLACKLEVELREP, IFD::SHORT, 2, brep);
266-
uint16_t cblack[] = { params->blackAt(0, 0), params->blackAt(1, 0),
267-
params->blackAt(0, 1), params->blackAt(1, 1) };
268-
rawIFD.addEntry(BLACKLEVEL, IFD::SHORT, 4, cblack);
269-
}
237+
uint16_t brep[2] = { 2, 2 };
238+
rawIFD.addEntry(BLACKLEVELREP, IFD::SHORT, 2, brep);
239+
uint16_t cblack[] = { 0, 0, 0, 0 };
240+
rawIFD.addEntry(BLACKLEVEL, IFD::SHORT, 4, cblack);
270241
uint32_t crop[2];
271242
crop[0] = 0;
272243
crop[1] = 0;

ImageIO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ QImage ImageIO::renderPreview(const Array2D<float> & rawData, const RawParameter
200200
for (size_t y = 0; y < params.rawHeight; ++y) {
201201
for (size_t x = 0; x < params.rawWidth; ++x) {
202202
size_t pos = y*params.rawWidth + x;
203-
int v = (rawData[pos] - params.blackAt(x ^ oddx, y ^ oddy)) * scale;
203+
int v = rawData[pos] * scale;
204204
if (v < 0) v = 0;
205205
else if (v > 65535) v = 65535;
206206
d.rawdata.raw_image[pos] = v;

ImageStack.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,10 @@ Array2D<float> ImageStack::compose(const RawParameters & params) const {
164164
}
165165
}
166166
dst.displace(params.leftMargin, params.topMargin);
167-
// Scale to params.max and recover the black levels
168-
size_t oddx = params.leftMargin & 1, oddy = params.topMargin + 1;
167+
// Scale to params.max
169168
for (size_t y = 0; y < params.rawHeight; ++y) {
170169
for (size_t x = 0; x < params.rawWidth; ++x) {
171-
dst(x, y) *= (params.max - params.maxBlack) / max;
172-
dst(x, y) += params.blackAt(x ^ oddx, y ^ oddy);
170+
dst(x, y) *= params.max / max;
173171
}
174172
}
175173

0 commit comments

Comments
 (0)