SadConsole
SadConsole copied to clipboard
Allow image (png, jpg, gig, etc) Overlay on parts of a console or cell.
Not sure if it's already possible but it would be great to be able to overlay/place, and if possible with z-index, an image such as a PNG, JPG, GIF, etc. on a console or on a cell.
Yes, this is possible. You just need to insert a DrawCallTexture
into the rendering system at the right spot. I'll write an article on how to do this.
Did you ever write up an article for this? I can't seem to figure out how to load the Texture2D
instance.
For anyone else wondering how to do this, the following code seems simplest (not sure if it's best, mediocre, worst, etc). Works for me on Linux.
In your Console
constructor:
FileStream fileStream = new FileStream("Content/filename-goes-here.png", FileMode.Open);
this.texture = Texture2D.FromStream(SadConsole.Global.GraphicsDevice, fileStream);
fileStream.Dispose();
Then, override Draw
:
override public void Draw(System.TimeSpan timeElapsed)
{
base.Draw(timeElapsed);
var drawCall = new SadConsole.DrawCalls.DrawCallTexture(texture, position);
SadConsole.Global.DrawCalls.Add(drawCall);
}
Et voila!
v9 has a component that can do this SadConsole.Components.DrawImage
which you just add to any console and an image will be drawn on it.
You fixed this three years later? You are a legend.
LOL @nightblade9 I fixed it a year ago but didn't close the bug 😬