internal TPaletteRecord(int aId, byte[] aData) : base(aId, aData) { if (Data.Length < 2 + XlsConsts.HighColorPaletteRange * 4 || GetWord(0) < XlsConsts.HighColorPaletteRange) { byte[] NewData = new byte[2 + XlsConsts.HighColorPaletteRange * 4]; SetWord(0, XlsConsts.HighColorPaletteRange); Array.Copy(Data, 0, NewData, 0, Data.Length); Array.Copy(StandardPalette.Data, Data.Length, NewData, Data.Length, NewData.Length - Data.Length); Data = NewData; } ColorLocator = new Dictionary <int, string>(); LabColorCache = new TLabColor[XlsConsts.HighColorPaletteRange - XlsConsts.LowColorPaletteRange + 1]; RgbColorCache = new Color [XlsConsts.HighColorPaletteRange - XlsConsts.LowColorPaletteRange + 1]; for (int i = XlsConsts.LowColorPaletteRange - 1; i < XlsConsts.HighColorPaletteRange; i++) { unchecked { Color aColor = ColorUtil.FromArgb((int)((uint)0xFF000000 | (uint)ColorUtil.BgrToRgb(GetColor(i)))); LabColorCache[i] = aColor; RgbColorCache[i] = aColor; ColorLocator[aColor.ToArgb()] = string.Empty; } } }
public void SetColor(int Index, Color aColor) { long Value = ColorUtil.BgrToRgb(aColor.ToArgb()); if ((Index >= Count) || (Index < 0)) { XlsMessages.ThrowException(XlsErr.ErrTooManyEntries, Index, Count - 1); } SetCardinal(2 + Index * 4, Value); ColorLocator.Remove(RgbColorCache[Index].ToArgb()); RgbColorCache[Index] = aColor; LabColorCache[Index] = aColor; ColorLocator[RgbColorCache[Index].ToArgb()] = string.Empty; }