【问题标题】:monogame - image quality after scalingmonogame - 缩放后的图像质量
【发布时间】:2018-01-25 08:38:20
【问题描述】:

我正在为单人游戏编写一个 GameObject 类(精灵的位置、alpha、旋转等...)

当我开始缩放图像时遇到了问题。有没有办法在不损失质量的情况下缩放图像?

这是我渲染所有内容的方式

foreach (KeyValuePair<int, GameObject> go in RenderObjects)
{
     spriteBatch.Draw(go.Value.img, go.Value.getRect(), go.Value.RenderArea, Color.White * (float)go.Value.alpha, (float)go.Value.rotation, go.Value.getCenter(), SpriteEffects.None, 0f);          
}

如果您尝试将 16x64 图像缩放到 160x640,会发生以下情况

Click to see the image

^^^^^^^^^^^^^^^^^^

【问题讨论】:

    标签: image scaling monogame blurry


    【解决方案1】:

    我一直在玩单机游戏,但我无意中找到了解决方案。 你只需要在 spriteBatch.Begin() 中添加一些参数;

    spriteBatch.Begin(... , ... ,SamplerState.PointClamp);
    
    foreach (KeyValuePair<int, GameObject> go in RenderObjects)
    {
         spriteBatch.Draw(go.Value.img, go.Value.getRect(), go.Value.RenderArea, Color.White * (float)go.Value.alpha, (float)go.Value.rotation, go.Value.getCenter(), SpriteEffects.None, 0f);
    }
    spriteBatch.End();
    

    实际上有更多方法可以做到这一点,但我不太明白如何做到这一点。与graphics.GraphicsDevice有关

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-27
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多