/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// This function based on code under ALv2 - Copyright 2013 István Ujj-Mészáros // credit Avisek Das and István Ujj-Mészáros staticvoid lcl_XYZtoRGB( float fX, float fY, float fZ, float& dR, float& dG, float& dB)
{ // Observer = 2°, Illuminant = D65
fX = fX / 100;
fY = fY / 100;
fZ = fZ / 100;
// X from 0 to 95.047
dR = fX * 3.2406 + fY * -1.5372 + fZ * -0.4986; // Y from 0 to 100.000
dG = fX * -0.9689 + fY * 1.8758 + fZ * 0.0415; // Z from 0 to 108.883
dB = fX * 0.0557 + fY * -0.2040 + fZ * 1.0570;
if (dR > 0.0031308)
{
dR = 1.055 * (std::pow(dR, 0.41666667)) - 0.055;
} else
{
dR = 12.92 * dR;
}
if (dB > 0.0031308)
{
dB = 1.055 * (std::pow(dB, 0.41666667)) - 0.055;
} else
{
dB = 12.92 * dB;
}
dR *= 255;
dG *= 255;
dB *= 255;
}
// This function based on code under ALv2 - Copyright 2013 István Ujj-Mészáros // credit Avisek Das and István Ujj-Mészáros staticvoid lcl_LABtoXYZ( float fL, float fa, float fb, float& dX, float& dY, float& dZ)
{
dY = (fL + 16) / 116;
dX = (fa / 500) + dY;
dZ = dY - (fb / 200);
if (std::pow(dY, 3) > 0.008856)
{
dY = std::pow(dY, 3);
} else
{
dY = (dY - 0.137931034) / 7.787;
}
if (nChunkType == 0xC0010000)
{ // Got a start chunk, so set palette name
maASEPaletteName = aPaletteName; // Is there color data? (shouldn't happen in a start block, but check anyway) if (nChunkSize > ((nChars * 2) + 2))
aPaletteName.clear(); else continue;
}
char cColorModel[5] = {0};
aFile.ReadBytes(cColorModel, 4);
OString aColorModel(cColorModel); // r, g, and b are floats ranging from 0 to 1 float r = 0, g = 0, b = 0;
if (aColorModel.equalsIgnoreAsciiCase("cmyk"))
{ float c = 0, m = 0, y = 0, k = 0;
aFile.ReadFloat(c);
aFile.ReadFloat(m);
aFile.ReadFloat(y);
aFile.ReadFloat(k);
lcl_CMYKtoRGB(c, m, y, k, r, g, b);
} elseif (aColorModel.equalsIgnoreAsciiCase("rgb "))
{
aFile.ReadFloat(r);
aFile.ReadFloat(g);
aFile.ReadFloat(b);
} elseif (aColorModel.equalsIgnoreAsciiCase("gray"))
{ float nVal = 0;
aFile.ReadFloat(nVal);
r = g = b = nVal;
} elseif (aColorModel.equalsIgnoreAsciiCase("LAB "))
{ float fL = 0, fA = 0, fB = 0;
aFile.ReadFloat(fL);
aFile.ReadFloat(fA);
aFile.ReadFloat(fB);
lcl_LABtoRGB(fL, fA, fB, r, g, b);
}
// Ignore color type
aFile.SeekRel(2);
maColors.emplace_back(Color(r * 255, g * 255, b * 255), aPaletteName);
}
// finds first token in rStr from index, separated by whitespace // returns position of next token in index static OString lcl_getToken(OStringBuffer& rStr, sal_Int32& index)
{
sal_Int32 substart, toklen = 0;
OUString aWhitespaceChars( u" \n\t"_ustr );
//counts to position of next token while(index < rStr.getLength() &&
aWhitespaceChars.indexOf( rStr[index] ) != -1 )
++index; if(index == rStr.getLength())
index = -1;
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.