mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Color adaptation for XYZ color space
This commit is contained in:
@ -218,6 +218,10 @@ public:
|
||||
{
|
||||
return m_values[row * Cols + column];
|
||||
}
|
||||
inline void setValue(size_t row, size_t column, PDFColorComponent value)
|
||||
{
|
||||
m_values[row * Cols + column] = value;
|
||||
}
|
||||
|
||||
void transpose()
|
||||
{
|
||||
@ -234,6 +238,33 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void makeIdentity()
|
||||
{
|
||||
Q_ASSERT(Rows == Cols);
|
||||
|
||||
m_values = { };
|
||||
|
||||
for (size_t row = 0; row < Rows; ++row)
|
||||
{
|
||||
const size_t index = row * Cols + row;
|
||||
m_values[index] = PDFColorComponent(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void makeDiagonal(auto diagonalItems)
|
||||
{
|
||||
Q_ASSERT(Rows == Cols);
|
||||
Q_ASSERT(diagonalItems.size() == Rows);
|
||||
|
||||
m_values = { };
|
||||
|
||||
for (size_t row = 0; row < Rows; ++row)
|
||||
{
|
||||
const size_t index = row * Cols + row;
|
||||
m_values[index] = diagonalItems[row];
|
||||
}
|
||||
}
|
||||
|
||||
void multiplyByFactor(PDFColorComponent factor)
|
||||
{
|
||||
for (auto it = begin(); it != end(); ++it)
|
||||
@ -249,6 +280,29 @@ private:
|
||||
std::array<PDFColorComponent, Rows * Cols> m_values;
|
||||
};
|
||||
|
||||
template<size_t i, size_t k, size_t j>
|
||||
static inline PDFColorComponentMatrix<i, j> operator*(const PDFColorComponentMatrix<i, k>& left, const PDFColorComponentMatrix<k, j>& right)
|
||||
{
|
||||
PDFColorComponentMatrix<i, j> result;
|
||||
|
||||
for (size_t ci = 0; ci < i; ++ci)
|
||||
{
|
||||
for (size_t cj = 0; cj < j; ++cj)
|
||||
{
|
||||
PDFColorComponent value = 0.0f;
|
||||
|
||||
for (size_t ck = 0; ck < k; ++ck)
|
||||
{
|
||||
value += left.getValue(ci, ck) * right.getValue(ck, cj);
|
||||
}
|
||||
|
||||
result.setValue(ci, cj, value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
using PDFColorComponentMatrix_3x3 = PDFColorComponentMatrix<3, 3>;
|
||||
|
||||
/// Represents PDF's color space (abstract class). Contains functions for parsing
|
||||
|
Reference in New Issue
Block a user