SadConsole icon indicating copy to clipboard operation
SadConsole copied to clipboard

Allow image (png, jpg, gig, etc) Overlay on parts of a console or cell.

Open piotrgulbis opened this issue 6 years ago • 3 comments

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.

piotrgulbis avatar Jan 13 '19 18:01 piotrgulbis

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.

ghost avatar Jan 13 '19 19:01 ghost

Did you ever write up an article for this? I can't seem to figure out how to load the Texture2D instance.

nightblade9 avatar Oct 20 '19 02:10 nightblade9

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!

image

nightblade9 avatar Oct 20 '19 02:10 nightblade9

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.

Thraka avatar Sep 10 '22 19:09 Thraka

You fixed this three years later? You are a legend.

nightblade9 avatar Sep 10 '22 22:09 nightblade9

LOL @nightblade9 I fixed it a year ago but didn't close the bug 😬

Thraka avatar Sep 14 '22 16:09 Thraka