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; }
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; }
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; }