/// <summary> /// Creates and returns a new Bitmap which contains a snapshot of all the DisplayObjectContainer's children. /// </summary> /// <returns>The Bitmap snapshot.</returns> public Bitmap GetFlattenedBitmap() { Bitmap retVal = new Bitmap((int)childBounds.Width, (int)childBounds.Height); using (Graphics g = System.Drawing.Graphics.FromImage(retVal)) { g.Clear(System.Drawing.Color.Transparent); g.DrawImageUnscaled(Graphics.Bitmap, new Point((int)Math.Abs(childBounds.X), (int)Math.Abs(childBounds.Y))); if (Texture != null) { Bitmap texture = TextureUtil.BitmapFromTexture(Texture); g.DrawImageUnscaled(texture, new Point((int)Math.Abs(childBounds.X), (int)Math.Abs(childBounds.Y))); texture.Dispose(); } for (int i = children.Count - 1; i >= 0; i--) { Bitmap childGraphics = children[i].Graphics.Bitmap; g.DrawImageUnscaled(childGraphics, new Point((int)(Math.Abs(childBounds.X) + children[i].X), (int)(Math.Abs(childBounds.Y) + children[i].Y))); childGraphics.Dispose(); if (children[i].Texture != null) { Bitmap childTexture = TextureUtil.BitmapFromTexture(children[i].Texture); g.DrawImageUnscaled(childTexture, new Point((int)(Math.Abs(childBounds.X) + children[i].X), (int)(Math.Abs(childBounds.Y) + children[i].Y))); childTexture.Dispose(); } } } return(retVal); }
public TextureAtlas(Texture texture, int columns, int rows) : this(TextureUtil.BitmapFromTexture(texture), columns, rows) { fromTexture = true; }
//constructor public TextureAtlas(Texture texture, XmlDocument atlasXml) : this(TextureUtil.BitmapFromTexture(texture), atlasXml) { fromTexture = true; }