34 mbValidPalette( false ),
36 maASEPaletteName ( rFName )
47 rColorSet.
InsertItem(nIx, rColor.first, rColor.second);
69 static void lcl_CMYKtoRGB(
float fCyan,
float fMagenta,
float fYellow,
float fKey,
float& dR,
float& dG,
float& dB )
71 fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
72 fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
73 fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
75 dR = std::clamp( 1.0 - fCyan, 0.0, 1.0 );
76 dG = std::clamp( 1.0 - fMagenta, 0.0, 1.0 );
77 dB = std::clamp( 1.0 - fYellow, 0.0, 1.0 );
87 if ((aFile.
ReadBytes(cMagic, 4) != 4) || (strncmp(cMagic,
"ASEF", 4) != 0))
96 sal_uInt32 nBlocks = 0;
98 for (sal_uInt32 nI = 0; nI < nBlocks; nI++) {
99 sal_uInt32 nChunkType = 0;
106 sal_uInt16 nChunkSize = 0;
107 sal_uInt16 nChars = 0;
111 OUString aPaletteName(
"");
117 if (nChunkType == 0xC0010000)
122 if (nChunkSize > ((nChars * 2) + 2))
123 aPaletteName.clear();
128 char cColorModel[5] = {0};
130 OString aColorModel(cColorModel);
132 float r = 0, g = 0, b = 0;
134 if (aColorModel.equalsIgnoreAsciiCase(
"cmyk"))
136 float c = 0,
m = 0,
y = 0, k = 0;
143 else if (aColorModel.equalsIgnoreAsciiCase(
"rgb "))
149 else if (aColorModel.equalsIgnoreAsciiCase(
"gray"))
157 float nL = 0, nA = 0, nB = 0;
167 maColors.emplace_back(
Color(r * 255, g * 255, b * 255), aPaletteName);
175 static OString
lcl_getToken(
const OString& rStr, sal_Int32& index);
178 mbLoadedPalette( false ),
179 mbValidPalette( false ),
208 rColorSet.
InsertItem(nIx, rColor.first, rColor.second);
221 OString aPaletteName;
224 if( !aLine.startsWith(
"GIMP Palette") )
return false;
226 if( aLine.startsWith(
"Name: ", &aPaletteName) )
228 maGPLPaletteName = OStringToOUString(aPaletteName, RTL_TEXTENCODING_ASCII_US);
230 if( aLine.startsWith(
"Columns: "))
259 if (aLine[0] !=
'#' && aLine[0] !=
'\n')
266 if(token.isEmpty() || nIndex == -1)
continue;
267 sal_Int32 r = token.toInt32();
270 if(token.isEmpty() || nIndex == -1)
continue;
271 sal_Int32 g = token.toInt32();
274 if(token.isEmpty())
continue;
275 sal_Int32 b = token.toInt32();
279 name = aLine.copy(nIndex);
283 OStringToOUString(name, RTL_TEXTENCODING_ASCII_US));
292 sal_Int32 substart, toklen = 0;
293 OUString aWhitespaceChars(
" \n\t" );
295 while(index < rStr.getLength() &&
296 aWhitespaceChars.indexOf( rStr[index] ) != -1)
298 if(index == rStr.getLength())
306 while(index < rStr.getLength() &&
307 aWhitespaceChars.indexOf( rStr[index] ) == -1 )
314 while(index < rStr.getLength() &&
315 aWhitespaceChars.indexOf( rStr[index] ) != -1 )
317 if(index == rStr.getLength())
320 return rStr.copy(substart, toklen);
326 mbLoadedPalette( false ),
328 maSOCPaletteName( rFName )
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nLen)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
virtual const OUString & GetName() override
virtual bool IsValid() override
PaletteGPL(const OUString &rFPath, const OUString &rFName)
OUString maASEPaletteName
sal_uInt64 SeekRel(sal_Int64 nPos)
virtual bool IsValid() override
virtual const OUString & GetName() override
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
bool ReadLine(OString &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
bool ReadPaletteHeader(SvFileStream &rFileStream)
virtual const OUString & GetPath() override
PaletteASE(const OUString &rFPath, const OUString &rFName)
virtual const OUString & GetPath() override
static XColorListRef AsColorList(rtl::Reference< XPropertyList > const &plist)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
virtual const OUString & GetPath() override
static OString lcl_getToken(const OString &rStr, sal_Int32 &index)
virtual ~PaletteASE() override
OUString maSOCPaletteName
SvStream & ReadFloat(float &rFloat)
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
virtual const OUString & GetName() override
virtual ~PaletteSOC() override
virtual ~PaletteGPL() override
std::size_t ReadBytes(void *pData, std::size_t nSize)
virtual bool IsValid() override
OUString maGPLPaletteName
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
void SetEndian(SvStreamEndian SvStreamEndian)
PaletteSOC(const OUString &rFPath, const OUString &rFName)
void addEntriesForXColorList(const XColorList &rXColorList, sal_uInt32 nStartIndex=1)
XColorListRef mpColorList
static void lcl_CMYKtoRGB(float fCyan, float fMagenta, float fYellow, float fKey, float &dR, float &dG, float &dB)
static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t, const OUString &rUrl)