Add premultiplied boolean flag for raw pixel data input (#2685)

This commit is contained in:
Michael Nutt
2021-05-03 14:30:37 -04:00
committed by GitHub
parent 309918a878
commit 9a1e8ed574
9 changed files with 60 additions and 1 deletions

View File

@@ -95,6 +95,7 @@ namespace sharp {
descriptor->rawChannels = AttrAsUint32(input, "rawChannels");
descriptor->rawWidth = AttrAsUint32(input, "rawWidth");
descriptor->rawHeight = AttrAsUint32(input, "rawHeight");
descriptor->rawPremultiplied = AttrAsBool(input, "rawPremultiplied");
}
// Multi-page input (GIF, TIFF, PDF)
if (HasAttr(input, "pages")) {
@@ -302,6 +303,9 @@ namespace sharp {
} else {
image.get_image()->Type = VIPS_INTERPRETATION_sRGB;
}
if (descriptor->rawPremultiplied) {
image = image.unpremultiply();
}
imageType = ImageType::RAW;
} else {
// Compressed data

View File

@@ -57,6 +57,7 @@ namespace sharp {
int rawChannels;
int rawWidth;
int rawHeight;
bool rawPremultiplied;
int pages;
int page;
int level;
@@ -80,6 +81,7 @@ namespace sharp {
rawChannels(0),
rawWidth(0),
rawHeight(0),
rawPremultiplied(false),
pages(1),
page(0),
level(0),