...
 
Commits (2)
......@@ -133,14 +133,12 @@ struct ExrPaintLayerSaveInfo {
struct EXRConverter::Private {
Private()
: doc(0)
, alphaWasModified(false)
, showNotifications(false)
{}
KisImageSP image;
KisDocument *doc;
bool alphaWasModified;
bool showNotifications;
QString errorMessage;
......@@ -295,39 +293,15 @@ struct GrayPixelWrapper
template <class WrapperType>
void EXRConverter::Private::unmultiplyAlpha(typename WrapperType::pixel_type *pixel)
{
typedef typename WrapperType::pixel_type pixel_type;
typedef typename WrapperType::channel_type channel_type;
WrapperType srcPixel(*pixel);
if (!srcPixel.checkMultipliedColorsConsistent()) {
channel_type newAlpha = srcPixel.alpha();
pixel_type __dstPixelData;
WrapperType dstPixel(__dstPixelData);
/**
* Division by a tiny alpha may result in an overflow of half
* value. That is why we use safe iterational approach.
*/
while (1) {
dstPixel.setUnmultiplied(srcPixel.pixel, newAlpha);
if (dstPixel.checkUnmultipliedColorsConsistent(srcPixel.pixel)) {
break;
}
newAlpha += alphaEpsilon<channel_type>();
alphaWasModified = true;
}
*pixel = dstPixel.pixel;
} else if (srcPixel.alpha() > 0.0) {
srcPixel.setUnmultiplied(srcPixel.pixel, srcPixel.alpha());
channel_type newAlpha = alphaEpsilon<channel_type>();
if (srcPixel.alpha() > newAlpha){
newAlpha = srcPixel.alpha();
}
srcPixel.setUnmultiplied(srcPixel.pixel, newAlpha);
}
template <typename T, typename Pixel, int size, int alphaPos>
......@@ -863,23 +837,6 @@ KisImageBuilder_Result EXRConverter::decode(const QString &filename)
// Set projectionColor to opaque
d->image->setDefaultProjectionColor(KoColor(Qt::transparent, colorSpace));
// After reading the image, notify the user about changed alpha.
if (d->alphaWasModified) {
QString msg =
i18nc("@info",
"The image contains pixels with zero alpha channel and non-zero "
"color channels. Krita has modified those pixels to have "
"at least some alpha. The initial values will <i>not</i> "
"be reverted on saving the image back."
"<br/><br/>"
"This will hardly make any visual difference just keep it in mind.");
if (d->showNotifications) {
QMessageBox::information(0, i18nc("@title:window", "EXR image has been modified"), msg);
} else {
warnKrita << "WARNING:" << msg;
}
}
if (!extraLayersInfo.isNull()) {
KisExrLayersSorter sorter(extraLayersInfo, d->image);
}
......