Allow color conversions using static arrays instead of just vectors (8e8c93de) · Commits · Martin Owens / inkscape · GitLab
Martin Owens
·
2026-05-19
·
via Martin Owens activity
| Original line number |
Diff line number |
Diff line |
|
@@ -9,13 +9,11 @@ set(colors_unit_SRC |
|
|
parser.cpp
|
|
|
printer.cpp
|
|
|
gradient-averager.cpp
|
|
|
spaces/alpha.cpp
|
|
|
spaces/base.cpp
|
|
|
spaces/cms.cpp
|
|
|
spaces/cmyk.cpp
|
|
|
spaces/components.cpp
|
|
|
spaces/gamut.cpp
|
|
|
spaces/gray.cpp
|
|
|
spaces/hsl.cpp
|
|
|
spaces/hsluv.cpp
|
|
|
spaces/hsv.cpp
|
|
@@ -24,8 +22,6 @@ set(colors_unit_SRC |
|
|
spaces/linear-rgb.cpp
|
|
|
spaces/luv.cpp
|
|
|
spaces/ok-color.cpp
|
|
|
spaces/okhsl.cpp
|
|
|
spaces/okhsv.cpp
|
|
|
spaces/oklab.cpp
|
|
|
spaces/oklch.cpp
|
|
|
spaces/named.cpp
|
|
@@ -49,6 +45,7 @@ set(colors_unit_SRC |
|
|
spaces/cms.h
|
|
|
spaces/cmyk.h
|
|
|
spaces/components.h
|
|
|
spaces/convert-static.h
|
|
|
spaces/enum.h
|
|
|
spaces/gamut.h
|
|
|
spaces/gray.h
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -264,14 +264,14 @@ const std::shared_ptr<TransformSurface> &System::getDisplayTransform() |
|
|
// No High bit depths here! Just low resolution gamma curved sRGB.
|
|
|
// TODO: Replace with something with a better gammut and depth.
|
|
|
TransformSurface::Format in = {
|
|
|
Profile::create_srgb(), // sRGB profile input
|
|
|
sizeof(char), // Char 8 per channel
|
|
|
true, // Integral
|
|
|
.profile = Profile::create_srgb(),
|
|
|
.byte_count = sizeof(char), // Char 8 per channel
|
|
|
.integral = true,
|
|
|
};
|
|
|
TransformSurface::Format out = {
|
|
|
display_profile,
|
|
|
sizeof(char),
|
|
|
true,
|
|
|
.profile = display_profile,
|
|
|
.byte_count = sizeof(char),
|
|
|
.integral = true,
|
|
|
};
|
|
|
_display_transform = std::make_shared<TransformSurface>(in, out);
|
|
|
} else {
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -26,6 +26,14 @@ public: |
|
|
|
|
|
bool do_transform(std::vector<double> &io) const;
|
|
|
|
|
|
template <typename In, typename Out>
|
|
|
bool do_transform(In const &i, Out &o)
|
|
|
{
|
|
|
assert(i.size() >= _channels_in && o.size() >= _channels_out);
|
|
|
cmsDoTransform(_handle, &i.front(), &o.front(), 1);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
|
|
|
int _channels_in;
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -27,6 +27,9 @@ class TransformContext |
|
|
fprintf(stderr, " ---- LCMS error: %s (ErrorCode: %d)\n", Text, ErrorCode);
|
|
|
}
|
|
|
public:
|
|
|
TransformContext(TransformContext const &) = delete;
|
|
|
TransformContext &operator=(TransformContext const &) = delete;
|
|
|
|
|
|
TransformContext()
|
|
|
: _context{cmsCreateContext(nullptr, nullptr)}
|
|
|
{
|
|
@@ -60,7 +63,7 @@ public: |
|
|
*/
|
|
|
struct Format
|
|
|
{
|
|
|
std::shared_ptr<Profile> const profile;
|
|
|
std::shared_ptr<Profile> profile;
|
|
|
|
|
|
int byte_count;
|
|
|
bool integral;
|
|
@@ -78,8 +81,8 @@ public: |
|
|
* @arg proof_intent - An optional intent for the proofing conversion
|
|
|
* @arg gamut_warn - Optional flag for rendering out of gamut colors with a warning color.
|
|
|
*/
|
|
|
TransformSurface(Format input,
|
|
|
Format output,
|
|
|
TransformSurface(Format const &input,
|
|
|
Format const &output,
|
|
|
RenderingIntent intent = RenderingIntent::PERCEPTUAL,
|
|
|
std::shared_ptr<Profile> const &proof = nullptr,
|
|
|
RenderingIntent proof_intent = RenderingIntent::AUTO,
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -159,7 +159,7 @@ bool Color::convert(Color const &other) |
|
|
*/
|
|
|
bool Color::convert(std::shared_ptr<Space::AnySpace> to_space)
|
|
|
{
|
|
|
if (!to_space || !to_space->isValid()) {
|
|
|
if (!to_space || !to_space->hasValidCmsProfile()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。