const BitmapColor& BitmapPalette::operator[](sal_uInt16 nIndex) const
{
assert(nIndex < mpImpl->GetBitmapData().size() && "Palette index is out of range"); return mpImpl->GetBitmapData()[nIndex];
}
BitmapColor& BitmapPalette::operator[](sal_uInt16 nIndex)
{
assert(nIndex < mpImpl->GetBitmapData().size() && "Palette index is out of range"); return mpImpl->GetBitmapData()[nIndex];
}
/// Returns the BitmapColor (i.e. palette index) that is either an exact match /// of the required color, or failing that, the entry that is the closest i.e. least error /// as measured by Color::GetColorError.
sal_uInt16 BitmapPalette::GetBestIndex(const BitmapColor& rCol) const
{ autoconst& rBitmapColor = mpImpl->GetBitmapData();
sal_uInt16 nRetIndex = 0;
if (!rBitmapColor.empty())
{ for (size_t j = 0; j < rBitmapColor.size(); ++j)
{ if (rCol == rBitmapColor[j])
{ return j;
}
}
sal_uInt16 nLastErr = SAL_MAX_UINT16; for (size_t i = 0; i < rBitmapColor.size(); ++i)
{ const sal_uInt16 nActErr = rCol.GetColorError(rBitmapColor[i]); if (nActErr < nLastErr)
{
nLastErr = nActErr;
nRetIndex = i;
}
}
}
return nRetIndex;
}
/// Returns the BitmapColor (i.e. palette index) that is an exact match /// of the required color. Returns SAL_MAX_UINT16 if nothing found.
sal_uInt16 BitmapPalette::GetMatchingIndex(const BitmapColor& rCol) const
{ autoconst& rBitmapColor = mpImpl->GetBitmapData();
for (size_t j = 0; j < rBitmapColor.size(); ++j)
{ if (rCol == rBitmapColor[j])
{ return j;
}
}
return SAL_MAX_UINT16;
}
bool BitmapPalette::IsGreyPaletteAny() const
{ autoconst& rBitmapColor = mpImpl->GetBitmapData(); constint nEntryCount = GetEntryCount(); if (!nEntryCount) // NOTE: an empty palette means 1:1 mapping returntrue; // See above: only certain entry values will result in a valid call to GetGreyPalette if (nEntryCount == 2 || nEntryCount == 4 || nEntryCount == 16 || nEntryCount == 256)
{ const BitmapPalette& rGreyPalette = Bitmap::GetGreyPalette(nEntryCount); if (rGreyPalette == *this) returntrue;
}
bool bRet = false; // TODO: is it worth to compare the entries for the general case? if (nEntryCount == 2)
{ const BitmapColor& rCol0(rBitmapColor[0]); const BitmapColor& rCol1(rBitmapColor[1]);
bRet = rCol0.GetRed() == rCol0.GetGreen() && rCol0.GetRed() == rCol0.GetBlue()
&& rCol1.GetRed() == rCol1.GetGreen() && rCol1.GetRed() == rCol1.GetBlue();
} return bRet;
}
bool BitmapPalette::IsGreyPalette8Bit() const
{ autoconst& rBitmapColor = mpImpl->GetBitmapData(); constint nEntryCount = GetEntryCount(); if (!nEntryCount) // NOTE: an empty palette means 1:1 mapping returntrue; if (nEntryCount != 256) returnfalse; for (sal_uInt16 i = 0; i < 256; ++i)
{ if (rBitmapColor[i] != BitmapColor(i, i, i)) returnfalse;
} returntrue;
}
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.