我想缩放
Texture2D
,但不使用 Draw()
方法。 这是因为在执行进一步的操作之前,我不会绘制 Texture2D
。 我将把 Texture2D
保存为字段。Texture2D
,但不使用 Draw()
方法。 这是因为在执行进一步的操作之前,我不会绘制 Texture2D
。 我将把 Texture2D
保存为字段。Texture2D.GetData
可以为您工作,但只适用于少量数据。如果您要对数百个图像执行此操作,将会严重拖慢游戏速度。我强烈建议使用自定义 Effect
进行一些后期处理效果。RenderTarget2D
对象上,然后从中获取颜色数据并随意操作数据。以下是示例:RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, textureWidth, textureHeight, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
GraphicsDevice.SetRenderTarget(renderTarget);
spriteBatch.Begin();
//scale and draw your texture here
spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
spriteBatch.Draw(renderTarget, new Rectangle(), Color.White);
renderTarget.GetData
来获取颜色数据,就像使用Texture2D
一样,并对其进行自己喜欢的操作。Texture2D.GetData
方法时遇到了Color[]
大小不正确的问题,而且我不确定如何获得正确的大小。 - eandr127Texture2D.GetData
并将你的纹理存储在一个 Color
、uint
数组中,然后进行缩放。