示例#1
0
        bool WritePalette(Document.Document tempDocument,
                          string CPCBitmapFilename)
        {
            int[] gateArrayPalette = null;

            gateArrayPalette = new int[16];
            for (int i = 0; i < 16; i++)
            {
                int palIndex = 0; // black as default color (unused)
                if (i < tempDocument.GetCPCPaletteIndices().Count)
                {
                    palIndex = tempDocument.GetCPCPaletteIndices()[i];
                }

                int gateArrayColor = tempDocument.GetCPCPaletteGateArray()[palIndex];

                int finalIndex = i + tempDocument.StartIndex;
                if (finalIndex < 16)
                {
                    gateArrayPalette[i + tempDocument.StartIndex] = gateArrayColor;
                }
            }

            var bitmapCompiler = BitmapCompiler.CreateCompiler(tempDocument.VideoMode);

            if (!bitmapCompiler.WritePalette(CPCBitmapFilename, gateArrayPalette, tempDocument.CPCAsicPalette))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        bool WriteFadePalette(Document.Document tempDocument,
                              string outputFadeFilename,
                              CPCBitmap.Document.Item item,
                              CPCBitmap.Document.Item targetItem)
        {
            int[]    fadeGateArrayPalette = new int[16];
            UInt16[] fadeCPCAsicPalette   = new UInt16[16] {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            for (int iClear = 0; iClear < 16; iClear++)
            {
                fadeGateArrayPalette[iClear] = tempDocument.GetCPCPaletteGateArray()[0];
            }

            for (int offset = 0; offset < item.IntermediateImage.Width * item.IntermediateImage.Height; offset++)
            {
                int palIndex       = item.IntermediateImage.Data[offset];
                int targetPalIndex = targetItem.IntermediateImage.Data[offset];

                int finalPalIndex  = tempDocument.GetCPCPaletteIndices()[palIndex];
                int gateArrayColor = tempDocument.GetCPCPaletteGateArray()[finalPalIndex];

                int finalIndex = targetPalIndex + tempDocument.StartIndex;
                if (finalIndex < 16)
                {
                    fadeGateArrayPalette[targetPalIndex + tempDocument.StartIndex] = gateArrayColor;
                }

                fadeCPCAsicPalette[targetPalIndex + tempDocument.StartIndex] = tempDocument.CPCAsicPalette[palIndex];
            }

            var bitmapCompiler = BitmapCompiler.CreateCompiler(tempDocument.VideoMode);

            if (!bitmapCompiler.WritePalette(outputFadeFilename, fadeGateArrayPalette, fadeCPCAsicPalette))
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        public void RefreshUIIndices()
        {
            bool failed = false;

            lvPalette.Items.Clear();
            for (int i = 0; i < Document.GetCPCPaletteIndices().Count; i++)
            {
                int index = Document.GetCPCPaletteIndices()[i];
                int color = Document.GetCPCPalette()[index];

                var item = new ListViewItem("" + (i + Document.StartIndex));                                 // Pen
                item.SubItems.Add("" + index);                                                               // Color
                item.SubItems.Add("0x" + String.Format("{0:X2}", Document.GetCPCPaletteGateArray()[index])); // Color (Gate Array)

                item.BackColor = Color.FromArgb(color);

                if (index < maxColors)
                {
                    item.ForeColor = Color.White;
                }
                else
                {
                    item.ForeColor = Color.Black;
                }

                if ((i + Document.StartIndex) >= maxColors)
                {
                    failed = true;
                }

                lvPalette.Items.Add(item);
            }

            if (failed)
            {
                PaletteLabel.ForeColor = Color.Red;
                PaletteLabel.Text      = "Invalid palette !";
            }
            else
            {
                PaletteLabel.ForeColor = Color.Green;
                PaletteLabel.Text      = "Palette is OK";
            }
        }