Use alpha-aware resize when alpha is used for transparency and it's not premultiplied.
This commit is contained in:
parent
4f576d5539
commit
242aa4254e
@ -701,23 +701,47 @@ void Compressor::Private::downsampleMipmap(Mipmap & mipmap, const InputOptions::
|
|||||||
mipmap.toFloatImage(inputOptions);
|
mipmap.toFloatImage(inputOptions);
|
||||||
|
|
||||||
const FloatImage * floatImage = mipmap.asFloatImage();
|
const FloatImage * floatImage = mipmap.asFloatImage();
|
||||||
|
FloatImage::WrapMode wrapMode = (FloatImage::WrapMode)inputOptions.wrapMode;
|
||||||
|
|
||||||
if (inputOptions.mipmapFilter == MipmapFilter_Box)
|
if (inputOptions.alphaMode == AlphaMode_Transparency)
|
||||||
{
|
{
|
||||||
// Use fast downsample.
|
if (inputOptions.mipmapFilter == MipmapFilter_Box)
|
||||||
mipmap.setImage(floatImage->fastDownSample());
|
{
|
||||||
|
BoxFilter filter;
|
||||||
|
mipmap.setImage(floatImage->downSample(filter, wrapMode, 3));
|
||||||
|
}
|
||||||
|
else if (inputOptions.mipmapFilter == MipmapFilter_Triangle)
|
||||||
|
{
|
||||||
|
TriangleFilter filter;
|
||||||
|
mipmap.setImage(floatImage->downSample(filter, wrapMode, 3));
|
||||||
|
}
|
||||||
|
else /*if (inputOptions.mipmapFilter == MipmapFilter_Kaiser)*/
|
||||||
|
{
|
||||||
|
nvDebugCheck(inputOptions.mipmapFilter == MipmapFilter_Kaiser);
|
||||||
|
KaiserFilter filter(inputOptions.kaiserWidth);
|
||||||
|
filter.setParameters(inputOptions.kaiserAlpha, inputOptions.kaiserStretch);
|
||||||
|
mipmap.setImage(floatImage->downSample(filter, wrapMode, 3));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (inputOptions.mipmapFilter == MipmapFilter_Triangle)
|
else
|
||||||
{
|
{
|
||||||
TriangleFilter filter;
|
if (inputOptions.mipmapFilter == MipmapFilter_Box)
|
||||||
mipmap.setImage(floatImage->downSample(filter, (FloatImage::WrapMode)inputOptions.wrapMode));
|
{
|
||||||
}
|
// Use fast downsample.
|
||||||
else /*if (inputOptions.mipmapFilter == MipmapFilter_Kaiser)*/
|
mipmap.setImage(floatImage->fastDownSample());
|
||||||
{
|
}
|
||||||
nvDebugCheck(inputOptions.mipmapFilter == MipmapFilter_Kaiser);
|
else if (inputOptions.mipmapFilter == MipmapFilter_Triangle)
|
||||||
KaiserFilter filter(inputOptions.kaiserWidth);
|
{
|
||||||
filter.setParameters(inputOptions.kaiserAlpha, inputOptions.kaiserStretch);
|
TriangleFilter filter;
|
||||||
mipmap.setImage(floatImage->downSample(filter, (FloatImage::WrapMode)inputOptions.wrapMode));
|
mipmap.setImage(floatImage->downSample(filter, wrapMode));
|
||||||
|
}
|
||||||
|
else /*if (inputOptions.mipmapFilter == MipmapFilter_Kaiser)*/
|
||||||
|
{
|
||||||
|
nvDebugCheck(inputOptions.mipmapFilter == MipmapFilter_Kaiser);
|
||||||
|
KaiserFilter filter(inputOptions.kaiserWidth);
|
||||||
|
filter.setParameters(inputOptions.kaiserAlpha, inputOptions.kaiserStretch);
|
||||||
|
mipmap.setImage(floatImage->downSample(filter, wrapMode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize mipmap.
|
// Normalize mipmap.
|
||||||
@ -737,7 +761,15 @@ void Compressor::Private::scaleMipmap(Mipmap & mipmap, const InputOptions::Priva
|
|||||||
|
|
||||||
// Resize image.
|
// Resize image.
|
||||||
BoxFilter boxFilter;
|
BoxFilter boxFilter;
|
||||||
mipmap.setImage(mipmap.asFloatImage()->resize(boxFilter, w, h, (FloatImage::WrapMode)inputOptions.wrapMode));
|
|
||||||
|
if (inputOptions.alphaMode == AlphaMode_Transparency)
|
||||||
|
{
|
||||||
|
mipmap.setImage(mipmap.asFloatImage()->resize(boxFilter, w, h, (FloatImage::WrapMode)inputOptions.wrapMode, 3));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mipmap.setImage(mipmap.asFloatImage()->resize(boxFilter, w, h, (FloatImage::WrapMode)inputOptions.wrapMode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user