private static void MapPixel(Dictionary <int, PixelMap[]> pixelMapping, int universe, ColorComponent colorComponent, int x, int y, ref int mappingPos) { PixelMap[] mapping; if (!pixelMapping.TryGetValue(universe, out mapping)) { mapping = new PixelMap[512]; pixelMapping.Add(universe, mapping); } mapping[mappingPos++] = new PixelMap { X = x, Y = y, ColorComponent = colorComponent }; }
public static Dictionary <int, PixelMap[]> GeneratePixelMappingFromGlediatorPatch(string fileName) { var channelMapping = new Dictionary <Tuple <Point, ColorComponent>, int>(); var universeIdMapping = new Dictionary <Point, int>(); var universeMapping = new Dictionary <int, int>(); using (var fs = File.OpenText(fileName)) { string line; string[] kvp; string[] parts; while ((line = fs.ReadLine()) != null) { if (line.StartsWith("Patch_Pixel_X_")) { kvp = line.Split('='); if (kvp.Length != 2) { continue; } parts = kvp[0].Split('_'); if (parts.Length != 8) { continue; } var pt = new Point(int.Parse(parts[3]), int.Parse(parts[5])); switch (parts[6]) { case "Ch": switch (parts[7]) { case "R": channelMapping[Tuple.Create(pt, ColorComponent.R)] = int.Parse(kvp[1]); break; case "G": channelMapping[Tuple.Create(pt, ColorComponent.G)] = int.Parse(kvp[1]); break; case "B": channelMapping[Tuple.Create(pt, ColorComponent.B)] = int.Parse(kvp[1]); break; } break; case "Uni": universeIdMapping[pt] = int.Parse(kvp[1]); break; } } else if (line.StartsWith("Patch_Uni_ID_")) { kvp = line.Split('='); if (kvp.Length != 2) { continue; } parts = kvp[0].Split('_'); if (parts.Length != 6) { continue; } if (parts[4] == "Uni" && parts[5] == "Nr") { universeMapping[int.Parse(parts[3])] = int.Parse(kvp[1]); } } } } var pixelMapping = new Dictionary <int, PixelMap[]>(); foreach (var kvp in channelMapping) { int universeId; if (!universeIdMapping.TryGetValue(kvp.Key.Item1, out universeId)) { continue; } int universe; if (!universeMapping.TryGetValue(universeId, out universe)) { continue; } PixelMap[] pMapping; if (!pixelMapping.TryGetValue(universe, out pMapping)) { pMapping = new PixelMap[512]; pixelMapping.Add(universe, pMapping); } if (kvp.Value >= 0 && kvp.Value <= 511) { pMapping[kvp.Value] = new PixelMap { ColorComponent = kvp.Key.Item2, X = kvp.Key.Item1.X, Y = kvp.Key.Item1.Y }; } } return(pixelMapping); }
private static void MapPixel(Dictionary<int, PixelMap[]> pixelMapping, int universe, ColorComponent colorComponent, int x, int y, ref int mappingPos) { PixelMap[] mapping; if (!pixelMapping.TryGetValue(universe, out mapping)) { mapping = new PixelMap[512]; pixelMapping.Add(universe, mapping); } mapping[mappingPos++] = new PixelMap { X = x, Y = y, ColorComponent = colorComponent }; }
public static Dictionary<int, PixelMap[]> GeneratePixelMappingFromGlediatorPatch(string fileName) { var channelMapping = new Dictionary<Tuple<Point, ColorComponent>, int>(); var universeIdMapping = new Dictionary<Point, int>(); var universeMapping = new Dictionary<int, int>(); using (var fs = File.OpenText(fileName)) { string line; string[] kvp; string[] parts; while ((line = fs.ReadLine()) != null) { if (line.StartsWith("Patch_Pixel_X_")) { kvp = line.Split('='); if (kvp.Length != 2) continue; parts = kvp[0].Split('_'); if (parts.Length != 8) continue; var pt = new Point(int.Parse(parts[3]), int.Parse(parts[5])); switch (parts[6]) { case "Ch": switch (parts[7]) { case "R": channelMapping[Tuple.Create(pt, ColorComponent.R)] = int.Parse(kvp[1]); break; case "G": channelMapping[Tuple.Create(pt, ColorComponent.G)] = int.Parse(kvp[1]); break; case "B": channelMapping[Tuple.Create(pt, ColorComponent.B)] = int.Parse(kvp[1]); break; } break; case "Uni": universeIdMapping[pt] = int.Parse(kvp[1]); break; } } else if (line.StartsWith("Patch_Uni_ID_")) { kvp = line.Split('='); if (kvp.Length != 2) continue; parts = kvp[0].Split('_'); if (parts.Length != 6) continue; if (parts[4] == "Uni" && parts[5] == "Nr") universeMapping[int.Parse(parts[3])] = int.Parse(kvp[1]); } } } var pixelMapping = new Dictionary<int, PixelMap[]>(); foreach (var kvp in channelMapping) { int universeId; if (!universeIdMapping.TryGetValue(kvp.Key.Item1, out universeId)) continue; int universe; if (!universeMapping.TryGetValue(universeId, out universe)) continue; PixelMap[] pMapping; if (!pixelMapping.TryGetValue(universe, out pMapping)) { pMapping = new PixelMap[512]; pixelMapping.Add(universe, pMapping); } if (kvp.Value >= 0 && kvp.Value <= 511) { pMapping[kvp.Value] = new PixelMap { ColorComponent = kvp.Key.Item2, X = kvp.Key.Item1.X, Y = kvp.Key.Item1.Y }; } } return pixelMapping; }