mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Fix tint op by ensuring LAB and allowing negative values #1235
Add test cases for more tint colours and input interpretations
This commit is contained in:
@@ -161,13 +161,14 @@ namespace sharp {
|
||||
if (typeBeforeTint == VIPS_INTERPRETATION_RGB) {
|
||||
typeBeforeTint = VIPS_INTERPRETATION_sRGB;
|
||||
}
|
||||
// Create 2 band image with every pixel set to the tint chroma
|
||||
std::vector<double> chromaPixel {a, b};
|
||||
VImage chroma = image.new_from_image(chromaPixel);
|
||||
// Extract luminance
|
||||
VImage luminance = image.colourspace(VIPS_INTERPRETATION_LAB)[0];
|
||||
// Create the tinted version by combining the L from the original and the chroma from the tint
|
||||
VImage tinted = luminance.bandjoin(chroma).colourspace(typeBeforeTint);
|
||||
std::vector<double> chroma {a, b};
|
||||
VImage tinted = luminance
|
||||
.bandjoin(chroma)
|
||||
.copy(VImage::option()->set("interpretation", VIPS_INTERPRETATION_LAB))
|
||||
.colourspace(typeBeforeTint);
|
||||
// Attach original alpha channel, if any
|
||||
if (HasAlpha(image)) {
|
||||
// Extract original alpha channel
|
||||
|
||||
@@ -683,7 +683,7 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
}
|
||||
|
||||
// Tint the image
|
||||
if (baton->tintA > 0 || baton->tintB > 0) {
|
||||
if (baton->tintA < 128.0 || baton->tintB < 128.0) {
|
||||
image = sharp::Tint(image, baton->tintA, baton->tintB);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,8 +157,8 @@ struct PipelineBaton {
|
||||
cropOffsetLeft(0),
|
||||
cropOffsetTop(0),
|
||||
premultiplied(false),
|
||||
tintA(0.0),
|
||||
tintB(0.0),
|
||||
tintA(128.0),
|
||||
tintB(128.0),
|
||||
flatten(false),
|
||||
negate(false),
|
||||
blurSigma(0.0),
|
||||
|
||||
Reference in New Issue
Block a user