mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Prefer use of vips_interpretation_max_alpha()
This also ensures we handle scRGB correctly, see:
e9c5a31552
This commit is contained in:
parent
94481a967e
commit
8e17c6f518
@ -951,14 +951,6 @@ namespace sharp {
|
|||||||
return interpretation == VIPS_INTERPRETATION_RGB16 || interpretation == VIPS_INTERPRETATION_GREY16;
|
return interpretation == VIPS_INTERPRETATION_RGB16 || interpretation == VIPS_INTERPRETATION_GREY16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Return the image alpha maximum. Useful for combining alpha bands. scRGB
|
|
||||||
images are 0 - 1 for image data, but the alpha is 0 - 255.
|
|
||||||
*/
|
|
||||||
double MaximumImageAlpha(VipsInterpretation const interpretation) {
|
|
||||||
return Is16Bit(interpretation) ? 65535.0 : 255.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Convert RGBA value to another colourspace
|
Convert RGBA value to another colourspace
|
||||||
*/
|
*/
|
||||||
@ -1033,7 +1025,7 @@ namespace sharp {
|
|||||||
VImage EnsureAlpha(VImage image, double const value) {
|
VImage EnsureAlpha(VImage image, double const value) {
|
||||||
if (!image.has_alpha()) {
|
if (!image.has_alpha()) {
|
||||||
std::vector<double> alpha;
|
std::vector<double> alpha;
|
||||||
alpha.push_back(value * sharp::MaximumImageAlpha(image.interpretation()));
|
alpha.push_back(value * vips_interpretation_max_alpha(image.interpretation()));
|
||||||
image = image.bandjoin_const(alpha);
|
image = image.bandjoin_const(alpha);
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
|
@ -357,12 +357,6 @@ namespace sharp {
|
|||||||
*/
|
*/
|
||||||
bool Is16Bit(VipsInterpretation const interpretation);
|
bool Is16Bit(VipsInterpretation const interpretation);
|
||||||
|
|
||||||
/*
|
|
||||||
Return the image alpha maximum. Useful for combining alpha bands. scRGB
|
|
||||||
images are 0 - 1 for image data, but the alpha is 0 - 255.
|
|
||||||
*/
|
|
||||||
double MaximumImageAlpha(VipsInterpretation const interpretation);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Convert RGBA value to another colourspace
|
Convert RGBA value to another colourspace
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|||||||
// Image is not opaque when alpha layer is present and contains a non-mamixa value
|
// Image is not opaque when alpha layer is present and contains a non-mamixa value
|
||||||
if (image.has_alpha()) {
|
if (image.has_alpha()) {
|
||||||
double const minAlpha = static_cast<double>(stats.getpoint(STAT_MIN_INDEX, bands).front());
|
double const minAlpha = static_cast<double>(stats.getpoint(STAT_MIN_INDEX, bands).front());
|
||||||
if (minAlpha != sharp::MaximumImageAlpha(image.interpretation())) {
|
if (minAlpha != vips_interpretation_max_alpha(image.interpretation())) {
|
||||||
baton->isOpaque = false;
|
baton->isOpaque = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user