Beispiel #1
0
        public static PaletteModel Create(MapPaletteBlock paletteBlock)
        {
            var paletteBuilder = PaletteBuilder.NewPaletteModel();

            paletteBuilder.SetName(paletteBlock.Name);
            paletteBuilder.CreateColors();
            for (int i = 0; i < paletteBlock.Value.Length; i++)
            {
                var colorData = paletteBlock.Value[i];
                paletteBuilder.SetColor(i, Color.FromArgb(255, colorData.R, colorData.G, colorData.B));
            }

            //for (int i = 64; i < paletteBlock.Value.Length; i++)
            //{
            //    var colorData = paletteBlock.Value[i];
            //    paletteBuilder.SetColor(i, Color.FromArgb(255, i, i, i));
            //}

            return(paletteBuilder.Build());
        }
Beispiel #2
0
        public static PaletteModel FromBinary(IModelsProvider dataProvider, IDbPaletteFromBinary entry)
        {
            if (entry.DataRef == null)
            {
                return(null);
            }

            var binaryModel = dataProvider.GetModel <BinaryModel>(entry.DataRef);

            if (binaryModel == null)
            {
                return(null);
            }

            //Remember to set source stream to begining
            binaryModel.Stream.Seek(entry.DataStart, SeekOrigin.Begin);

            var paletteBuilder = PaletteBuilder.NewPaletteModel();
            var paletteReader  = new PaletteReader(paletteBuilder, ToPaletteMode(entry.Mode), entry.ColorsNo);

            return(paletteReader.Read(binaryModel.Stream));
        }