// Determine the color space in which the gainmap math is to be applied.
sk_sp<SkColorSpace> gainmapMathColorSpace =
gainmapInfo.fGainmapMathColorSpace
? gainmapInfo.fGainmapMathColorSpace->makeLinearGamma()
: baseColorSpace->makeLinearGamma(); if (!dstColorSpace) {
dstColorSpace = SkColorSpace::MakeSRGB();
}
// Compute the weight parameter that will be used to blend between the images. float W = 0.f; if (dstHdrRatio > gainmapInfo.fDisplayRatioSdr) { if (dstHdrRatio < gainmapInfo.fDisplayRatioHdr) {
W = (std::log(dstHdrRatio) - std::log(gainmapInfo.fDisplayRatioSdr)) /
(std::log(gainmapInfo.fDisplayRatioHdr) -
std::log(gainmapInfo.fDisplayRatioSdr));
} else {
W = 1.f;
}
}
constbool baseImageIsHdr = (gainmapInfo.fBaseImageType == SkGainmapInfo::BaseImageType::kHDR); if (baseImageIsHdr) {
W -= 1.f;
}
// Return the base image directly if the gainmap will not be applied at all. if (W == 0.f) { return baseImage->makeShader(baseSamplingOptions, &baseRectToDstRect);
}
// Create a color filter to transform from the base image's color space to the color space in // which the gainmap is to be applied. auto colorXformSdrToGainmap =
SkColorFilterPriv::MakeColorSpaceXform(baseColorSpace, gainmapMathColorSpace);
// Create a color filter to transform from the color space in which the gainmap is applied to // the destination color space. auto colorXformGainmapToDst =
SkColorFilterPriv::MakeColorSpaceXform(gainmapMathColorSpace, dstColorSpace);
// The base image shader will convert into the color space in which the gainmap is applied. auto baseImageShader = baseImage->makeRawShader(baseSamplingOptions, &baseRectToDstRect)
->makeWithColorFilter(colorXformSdrToGainmap);
// The gainmap image shader will ignore any color space that the gainmap has. auto gainmapImageShader =
gainmapImage->makeRawShader(gainmapSamplingOptions, &gainmapRectToDstRect);
// Return a shader that will apply the gainmap and then convert to the destination color space. return gainmapMathShader->makeWithColorFilter(colorXformGainmapToDst);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.