示例#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 WriteFirmwarePalette(Document.Document tempDocument,
                                  string CPCBitmapFirmwareFilename)
        {
            int[] firmwarePalette = null;

            firmwarePalette = 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 firmwareColor = palIndex;

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

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

            if (!bitmapCompiler.WritePalette(CPCBitmapFirmwareFilename, firmwarePalette, null))
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        public void CreateProcessedImages()
        {
            processedImages = new List <Image>();

            foreach (Document.Item item in Document.Items)
            {
                Document.IntermediateImage intermediateImage = item.IntermediateImage;

                Bitmap processedBitmap = new Bitmap(intermediateImage.Width * XIncrement, intermediateImage.Height, PixelFormat.Format24bppRgb);

                for (int y = 0; y < intermediateImage.Height; y++)
                {
                    for (int x = 0; x < intermediateImage.Width; x++)
                    {
                        /* from 0 to 15 */
                        int pen = intermediateImage.Data[(y * intermediateImage.Width) + x];

                        /* from 0 to 26 */
                        int color = 0; // default color
                        if (pen < Document.GetCPCPaletteIndices().Count)
                        {
                            color = Document.GetCPCPaletteIndices()[pen];
                        }

                        /* argb */
                        int argb = Document.GetCPCPalette()[color];

                        Color processedColor = Color.FromArgb(argb);

                        int xStart = x * XIncrement;
                        for (int i = 0; i < XIncrement; i++)
                        {
                            processedBitmap.SetPixel(xStart + i, y, processedColor);
                        }
                    }
                }

                processedImages.Add((Image)processedBitmap);
            }
        }
示例#4
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);
        }