Alternative for Texture2D.FromStream(graphicsDevice, stream, width, height, zoom)?


I’m new to Monogame and have been trying to port an XNAGame released 5 years ago for the last few days.

I have an image that comes from the user and the downstream code really wants this to be 1536x2048, and the files loaded were always either 1536x2048 or smaller, but always with the same 3:4 ratio.

The solution was simple :
var tex = Texture2D.FromStream(graphicsDevice:graphicsDevice, stream:titleStream,width:1536,height:2048,zoom:true);

However the overload with width, height, zoom does not exist in monogame.

Any suggestions to load a texture from file/stream at a specific size different from the source image?

Load the texture at it’s original size into a Texture2D.
Create a RenderTarget of the output size you want.
Render the input texture into the render target with SpriteBatch

1 Like


I think that should have worked…

I can’t believe I posted this question before figuring out the entire function was dead code and the real function was elsewhere. I hate my old self for leaving dead code like that :-/