public Bitmap Render(TextureAtlas atlas) { var result = new Bitmap( atlas.Size.Width, atlas.Size.Height, _settings.PixelFormat ); using (var g = Graphics.FromImage(result)) { g.Clear(_settings.MatteColor); atlas.Nodes.ToList().ForEach(n => { if(n.IsRotated) n.Texture.RotateFlip(RotateFlipType.Rotate90FlipNone); if (n.Reference == null) ; g.DrawImage(n.Texture, n.X, n.Y); }); } return result; }
public void Render_with_valid_input_produces_expected_output() { var atlas = new TextureAtlas { Size = new Size(512, 512), Nodes = new[]{ new TextureAtlasNode{ Texture = Properties.Resources.boss3, X = 1, Y = 1, }, new TextureAtlasNode{ Texture = Properties.Resources.boss4, X = 1, Y = 130, }, new TextureAtlasNode{ Texture = Properties.Resources.boss2, X = 258, Y = 1, }, new TextureAtlasNode{ Texture = Properties.Resources.boss1, X = 258, Y = 98, }, new TextureAtlasNode{ Texture = Properties.Resources.ghost1, X = 379, Y = 1, }, new TextureAtlasNode{ Texture = Properties.Resources.ghost2, X = 379, Y = 44, }, new TextureAtlasNode{ Texture = Properties.Resources.La_Funk, X = 415, Y = 87, }, }, }; var renderer = new TextureAtlasRenderer(new TextureAtlasRendererSettings { MatteColor = Color.Fuchsia, PixelFormat = PixelFormat.Format32bppPArgb, }); var result = renderer.Render(atlas); Assert.True(TestExtensions.AreEqual(Properties.Resources.renderer_expected_1, result)); }
private void Render(TextureAtlas atlas, [CallerMemberName]string memberName = "") { var renderer = new TextureAtlasRenderer(new TextureAtlasRendererSettings { MatteColor = Color.FromArgb(128, 255, 0, 255), PixelFormat = PixelFormat.Format32bppArgb, }); var result = renderer.Render(atlas); result.Dump(@"C:\" + memberName + "___"); }