public GraphicTile(GraphicTile OtherTile) { Width = OtherTile.Width; Height = OtherTile.Height; Mode = OtherTile.Mode; Colors = OtherTile.Colors; CustomColor = OtherTile.CustomColor; TransparentColorIndex = OtherTile.TransparentColorIndex; Data = new ByteBuffer(OtherTile.Data); Image = new GR.Image.MemoryImage(OtherTile.Image); }
public int MapPixelColor(int X, int Y, GraphicTile TargetTile) { int pixelValue = GetPixel(X, Y); if (Mode == TargetTile.Mode) { return(pixelValue); } // now things are getting funny uint pixelColor = GetColorFromValue(pixelValue); var potentialColors = new List <uint>(); switch (TargetTile.Mode) { case GraphicTileMode.COMMODORE_HIRES: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); // TODO - variable color! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); break; case GraphicTileMode.COMMODORE_MULTICOLOR: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); potentialColors.Add(Colors.Palette.ColorValues[Colors.MultiColor1]); potentialColors.Add(Colors.Palette.ColorValues[Colors.MultiColor2]); // TODO - variable color! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); break; case GraphicTileMode.COMMODORE_ECM: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); potentialColors.Add(Colors.Palette.ColorValues[Colors.BGColor4]); // TODO - variable colors! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); break; case GraphicTileMode.MEGA65_FCM_16_COLORS: case GraphicTileMode.MEGA65_FCM_256_COLORS: potentialColors.AddRange(Colors.Palette.ColorValues); break; } int bestMatch = FindClosestEntryInPalette(pixelColor, potentialColors); return(bestMatch); }
public int MapPixelColor(int X, int Y, GraphicTile TargetTile) { int pixelValue = GetPixel(X, Y); if (Mode == TargetTile.Mode) { return(pixelValue); } // now things are getting funny uint pixelColor = GetColorFromValue(pixelValue); var potentialColors = new List <uint>(); var potentialColorTypes = new List <ColorType>(); switch (TargetTile.Mode) { case GraphicTileMode.COMMODORE_HIRES: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); potentialColorTypes.Add(ColorType.BACKGROUND); // TODO - variable color! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); potentialColorTypes.Add(ColorType.CUSTOM_COLOR); break; case GraphicTileMode.COMMODORE_MULTICOLOR: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); potentialColorTypes.Add(ColorType.BACKGROUND); potentialColors.Add(Colors.Palette.ColorValues[Colors.MultiColor1]); potentialColorTypes.Add(ColorType.MULTICOLOR_1); potentialColors.Add(Colors.Palette.ColorValues[Colors.MultiColor2]); potentialColorTypes.Add(ColorType.MULTICOLOR_2); // TODO - variable color! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); potentialColorTypes.Add(ColorType.CUSTOM_COLOR); break; case GraphicTileMode.COMMODORE_ECM: potentialColors.Add(Colors.Palette.ColorValues[Colors.BackgroundColor]); potentialColorTypes.Add(ColorType.BACKGROUND); potentialColors.Add(Colors.Palette.ColorValues[Colors.BGColor4]); potentialColorTypes.Add(ColorType.BGCOLOR4); // TODO - variable colors! potentialColors.Add(Colors.Palette.ColorValues[CustomColor]); potentialColorTypes.Add(ColorType.CUSTOM_COLOR); break; case GraphicTileMode.MEGA65_NCM: case GraphicTileMode.MEGA65_FCM_256_COLORS: for (int i = 0; i < Colors.Palette.NumColors; ++i) { potentialColors.Add(Colors.Palette.ColorValues[i]); potentialColorTypes.Add((ColorType)i); } break; } int bestMatch = FindClosestEntryInPalette(pixelColor, potentialColorTypes, potentialColors); return(bestMatch); }