// All color profile information from an SkCodec. // TODO(https://issues.skia.org/issues/464217864): This should include skhdr::Metadata. class ColorProfile {
public: // Create a ColorProfile from an SkData for an ICC profile. // Returns nullptr if the data fails to parse. This will use // either MakeICCProfileWithSkCMS or MakeICCProfileWithRust // depending on the build configuration. static std::unique_ptr<ColorProfile> MakeICCProfile(sk_sp<const SkData>);
// Implementation of MakeICCProfile that uses skcms to parse. // This should only be called by tests. static std::unique_ptr<ColorProfile> MakeICCProfileWithSkCMS(sk_sp<const SkData>);
// Create a ColorProfile from an SkColorSpace. Returns nullptr if the color space is // nullptr. static std::unique_ptr<ColorProfile> Make(sk_sp<SkColorSpace>);
// Create a ColorProfile from the specified matrix and transfer curves. This will always // succeed. static std::unique_ptr<ColorProfile> Make(const skcms_TransferFunction& trfn, const skcms_Matrix3x3& toXYZD50);
// Create a ColorProfile with the specified CICP values. This will always succeed, even if // the values are unrecognized. static std::unique_ptr<ColorProfile> MakeCICP(uint8_t color_primaries,
uint8_t transfer_characteristics,
uint8_t matrix_coefficients,
uint8_t full_range_flag);
// Create a copy of this.
std::unique_ptr<ColorProfile> clone() const;
// Return the color data space for the profile. enumclass DataSpace {
kRGB, // skcms_Signature_RGB
kCMYK, // skcms_Signature_CMYK
kGray, // skcms_Signature_Gray
kOther, // all other values
};
DataSpace dataSpace() const;
// Return the color space that this profile represents exactly. Return nullptr if this profile // cannot be represented as an SkColorSpace.
sk_sp<SkColorSpace> getExactColorSpace() const;
// Return the color space that Android uses for this profile (see implementation for details). // Will not return nullptr.
sk_sp<SkColorSpace> getAndroidOutputColorSpace() const;
// TODO(https://issues.skia.org/issues/464217864): Remove direct access to the // skcms_ICCProfile and change data() to be a serialize() function. const skcms_ICCProfile* profile() const { return &fProfile; }
sk_sp<const SkData> data() const { return fData; }
// Opaque handle that keeps alive any externally-allocated data that // fProfile's raw pointers (e.g. A2B grid/curve tables) reference.
std::shared_ptr<void> fRetainedData;
};
} // namespace SkCodecs
class SkCodecPriv final {
public: staticconst SkEncodedInfo& GetEncodedInfo(const SkCodec* codec) {
SkASSERT(codec); return codec->getEncodedInfo();
}
/* *Whenscaling,wewilldiscardcertainy-coordinates(rows)and *x-coordinates(columns).Thisfunctionreturnstrueifweshouldkeepthe *coordinateandfalseotherwise. *Theinputsmaybex-coordinatesory-coordinates. * *ThisdoesnotneedtobecalledandisnotcalledwhensampleFactor==1.
*/ staticbool IsCoordNecessary(int srcCoord, int sampleFactor, int scaledDim) { // Get the first coordinate that we want to keep int startCoord = GetStartCoord(sampleFactor);
// Return false on edge cases if (srcCoord < startCoord || GetDstCoord(srcCoord, sampleFactor) >= scaledDim) { returnfalse;
}
// Every sampleFactor rows are necessary return ((srcCoord - startCoord) % sampleFactor) == 0;
}
if (srcIsOpaque) { if (kOpaque_SkAlphaType != dstAlpha) {
SkCodecPrintf( "Warning: an opaque image should be decoded as opaque " "- it is being decoded as non-opaque, which will draw slower\n");
} return true;
}
static SkPMColor PremultiplyARGBasRGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { if (a != 255) {
r = SkMulDiv255Round(r, a);
g = SkMulDiv255Round(g, a);
b = SkMulDiv255Round(b, a);
}
return SkPackARGB_as_RGBA(a, r, g, b);
}
static SkPMColor PremultiplyARGBasBGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { if (a != 255) {
r = SkMulDiv255Round(r, a);
g = SkMulDiv255Round(g, a);
b = SkMulDiv255Round(b, a);
}
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.