public void BasicExchangeEngineTest() { var tsfinder = new TileSetRepo.TileSetRepo(); tsfinder.Discover(); var tileset_stars = (IHueMatchingTileset)tsfinder.ByName("Stars (16x16)")[0]; var tileset_para16 = (IHueMatchingTileset)tsfinder.ByName("16 pastels (8x8)")[0]; var loader = new TesselatedImageLoader(); var tesser = new Basic16Tesselator(); var loaded_image = loader.LoadFromImagelibrary("green_leaf.jpg", tesser); var writer = new ImageWriter(); var output_path = UserSettings.GetDefaultPath("output_path"); var assembled_bitmap_pre = loaded_image.AssembleFragments(); writer.WriteBitmap(assembled_bitmap_pre, System.IO.Path.Combine(output_path, "green_leaf_unchanged.jpg")); new BasicExchangeEngine(tileset_stars, loaded_image).run(); var assembled_bitmap_stars = loaded_image.AssembleFragments(); writer.WriteBitmap(assembled_bitmap_stars, System.IO.Path.Combine(output_path, "stars_leaf_output.jpg")); new BasicExchangeEngine(tileset_para16, loaded_image).run(); var assembled_bitmap_para16 = loaded_image.AssembleFragments(); writer.WriteBitmap(assembled_bitmap_para16, System.IO.Path.Combine(output_path, "parametric_leaf_output.jpg")); }
// Lazy. protected void LazyUpdate() { if (!NeedsUpdate) { return; } if (InputImageName is null || TileSet is null || !File.Exists(InputImageName)) { NeedsUpdate = false; return; } System.Console.WriteLine("TSR loaded {0} tilesets.", tsr.NumberOfTilesets()); try { var buffer = System.IO.File.ReadAllBytes(InputImageName); var pixbuf = new Gdk.Pixbuf(buffer); var image = new Gtk.Image(pixbuf); foreach (var win in update_targets) { win.SetInputPixbuf(pixbuf); } } catch (Exception exx) { System.Console.WriteLine("LazyUpdate could not update image, caused exception {0} for {1} ", exx.ToString(), InputImageName); } try { var tesser = new Basic16Tesselator(); var loader = new TesselatedImageLoader(); var loaded_image = loader.LoadFromImagelibrary(InputImageName, tesser); var writer = new ImageWriter(); new TileExchange.BasicExchangeEngine((IHueMatchingTileset)TileSet, loaded_image).run(); var assembled_bitmap_pre = loaded_image.AssembleFragments(); writer.WriteBitmap(assembled_bitmap_pre, System.IO.Path.Combine("/tmp", "foo.png")); MemoryStream ms = new MemoryStream(); assembled_bitmap_pre.Save(ms, ImageFormat.Png); ms.Position = 0; var pixbuf = new Gdk.Pixbuf(ms); update_targets[0].SetOutputPixbuf(pixbuf); } catch (Exception exx) { System.Console.WriteLine("LazyUpdate could not generate image, caused exception {0} for {1} ", exx.ToString(), InputImageName); } }
public void DocumentationImage() { var tsfinder = new TileSetRepo.TileSetRepo(); tsfinder.Discover(UserSettings.GetDefaultPath("tileset_path"), false); var tileset = (IHueMatchingTileset)tsfinder.ByName("Noisy Pastels (16x16)")[0]; var loader = new TesselatedImageLoader(); var tesser = new Basic16Tesselator(); var loaded_image = loader.LoadFromImagelibrary("Polse.jpg", tesser); var writer = new ImageWriter(); var output_path = UserSettings.GetDefaultPath("output_path"); new BasicExchangeEngine(tileset, loaded_image).run(); var assembled_bitmap_pre = loaded_image.AssembleFragments(); writer.WriteBitmap(assembled_bitmap_pre, System.IO.Path.Combine(output_path, "Pastellized Polse.png")); }