More texture scaling problems

Simplified background: I have a texture that is 512x512, and I want to display it as the backdrop to a scene, the window size of which is currently 800x600. I need to load the texture from a stream rather than a file.

I have loaded the texture, created a SpriteBatch, and am calling the equivalent of spriteBatch.Draw(texture, new Rectangle(0,0,800,600),Color.White); but it isn't exhibiting the expected behaviour(drawing a quad across the whole window). It is drawing the area 0,0,512,512... I've tried it with different texture sizes (smaller ones) and it seems to be drawing at the textures size, and completely ignoring the Rectangle's size. Is it really supposed to do that ?

Using spriteBatch.Draw(texture, new Rectangle(0,0,800,600), new Rectangle(0,0,texture.Width,texture.Height,Color.White); stretches the last pixel on the right/bottom edge to the edge of the screen, so that's out too.

Without fixed function, I have no clue how to do a VertexBuffer of CustomVertex.TransformedTextured, so that's out..

So.. how the heck do I draw it scaled to full screen ?

[1107 byte] By [Braneloc] at [2007-12-24]
# 1

Are you setting any render states or sampler states before you draw the background? I was able to get a larger and smaller texture to fill the window by using the same code with a default project:

sprites.Begin();

sprites.Draw(this.background, new Rectangle(0, 0, 800, 600), Color.White);

sprites.End();

MitchWalker-MSFT at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2

I've been testing a lot further, the only thing different is I'm using SpriteBlendMode.AlphaBlend, but that isn't the problem, I've not set any other device stuff that would mess it up. Thanks for pointing out that it seems to work ok for textures loaded from file - but when trying to load from a Stream, the loaded texture size overrides the scaling in Sprite.Draw, so I guess I need to change my original question slightly:

How do I load a texture from Stream and draw it scaled ?

(Loading from stream, saving to file, and reloading kinda defeats the point... Stream loading is WAY more important than a file. If I can use a block copy from a System.Drawing.Image or similar that'd be fine, though I'm not sure if that's good practice with xna or if/how they interact. Or should I be looking at GetData/SetData and putting that into a Stream ? Not sure which is the best way to go.)

Braneloc at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3
Please try using Beta 2 to see if this still reproduces. You should use the ContentManager to load your textures now.
MitchWalker-MSFT at 2007-8-31 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...