Commit e6e7b467 authored by Amy spark's avatar Amy spark 👉
Browse files

JPEG-XL: fix import/export of HDR alpha channels

CCBUG: 460380
parent a5d1d31d
......@@ -86,11 +86,11 @@ inline QByteArray writeLayer(const int width,
for (int x = 0; x < width; x++) {
CSTrait::normalisedChannelsValue(it->rawDataConst(), pixelValues);
if (!convertToRec2020 && !isLinear) {
for (int i = 0; i < 4; i++) {
for (int i = 0; i < channels; i++) {
src[i] = static_cast<double>(dst[i]);
}
profile->linearizeFloatValue(pixelValuesLinear);
for (int i = 0; i < 4; i++) {
for (int i = 0; i < channels; i++) {
dst[i] = static_cast<float>(src[i]);
}
}
......@@ -100,7 +100,12 @@ inline QByteArray writeLayer(const int width,
}
for (int ch = 0; ch < channels; ch++) {
dst[ch] = applyCurveAsNeeded<conversionPolicy>(dst[ch]);
if (ch == CSTrait::alpha_pos) {
dst[ch] = applyCurveAsNeeded<ConversionPolicy::KeepTheSame>(
dst[ch]);
} else {
dst[ch] = applyCurveAsNeeded<conversionPolicy>(dst[ch]);
}
}
if (swap) {
......
......@@ -104,14 +104,21 @@ inline void imageOutCallback(void *that, size_t x, size_t y, size_t numPixels, c
const double *lCoef = data->lCoef.constData();
QVector<float> pixelValues(static_cast<int>(cs->channelCount()));
float *tmp = pixelValues.data();
const quint32 alphaPos = cs->alphaPos();
for (size_t i = 0; i < numPixels; i++) {
for (size_t i = 0; i < channels; i++) {
tmp[i] = 0;
tmp[i] = 1.0;
}
for (size_t ch = 0; ch < channels; ch++) {
tmp[ch] = value<policy, channelsType>(src, ch);
if (ch == alphaPos) {
tmp[ch] = value<policy, channelsType>(src, ch);
} else {
tmp[ch] =
value<LinearizePolicy::KeepTheSame, channelsType>(src,
ch);
}
}
if (swap) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment