public static void testRead(String file) { // register with factory chunk PngChunk.FactoryRegister(PngChunkSERI.ID, typeof(PngChunkSERI)); // read all file PngReader pngr = FileHelper.CreatePngReader(file); pngr.ReadSkippingAllRows(); pngr.End(); // we assume there can be at most one chunk of this type... PngChunk chunk = pngr.GetChunksList().GetById1(PngChunkSERI.ID); // This would work even if not registered, but then PngChunk would be of type PngChunkUNKNOWN Console.Out.WriteLine(chunk); // the following would fail if we had not register the chunk PngChunkSERI chunkprop = (PngChunkSERI)chunk; string name = chunkprop.GetObj().name; int age = chunkprop.GetObj().age; Console.Out.WriteLine("Done. Name: " + name + " age=" + age); }
static void Main(string[] args) { if (args.Length != 2) { MessageBox.Show("Invalid number of parameters. Usage: ImageOcclusionEditor.exe <background-image-path> <occlusion-image-path>"); return; } string backgroundImg = args[0]; string occlusionImg = args[1]; if (!File.Exists(backgroundImg)) { MessageBox.Show(String.Format("Background file {0} doesn't exist", backgroundImg)); return; } if (!File.Exists(occlusionImg)) { MessageBox.Show(String.Format("Occlusion file {0} doesn't exist", occlusionImg)); return; } if (!ValidateImage(backgroundImg)) { MessageBox.Show(String.Format("Background file {0} isn't a known Image Format", backgroundImg)); return; } if (!ValidateImage(occlusionImg)) { MessageBox.Show(String.Format("Occlusion file {0} isn't a known Image Format", occlusionImg)); return; } PngChunk.FactoryRegister(PngChunkSVGI.ID, typeof(PngChunkSVGI)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(backgroundImg, occlusionImg)); }
static PngSkin() { PngChunk.FactoryRegister(PngChunkSKIN.ID, typeof(PngChunkSKIN)); }