添加 Vector2 会使图像变得模糊

发布于 2024-12-20 05:44:57 字数 874 浏览 7 评论 0原文

我有这段代码(XNA 4):

int col = 0;
int row = 0;
foreach (Tile tile in TileList)
{
    if (col > NumTiles.X) {
        row++;
    }
    tile.Position = new Vector2(TileDimensions.X / 2, TileDimensions.Y / 2) + new Vector2(col * TileDimensions.X, row * TileDimensions.Y) + Margins + Position;
    col++;
}

我的问题是它使瓷砖变得模糊。

如果我改用此代码(我从该位置删除第一个 Vector2):

int col = 0;
int row = 0;
foreach (Tile tile in TileList)
{
    if (col > NumTiles.X) {
        row++;
    }
    tile.Position = new Vector2(col * TileDimensions.X, row * TileDimensions.Y) + Margins + Position;
    col++;
}

它会很好地绘制它们。

图片:

低分辨率

高分辨率

编辑:我刚刚发现我需要将数字转换为整数,或者 spritebatch 在像素之间做了一些时髦的事情,这恰好模糊了我的图像

I have this code (XNA 4):

int col = 0;
int row = 0;
foreach (Tile tile in TileList)
{
    if (col > NumTiles.X) {
        row++;
    }
    tile.Position = new Vector2(TileDimensions.X / 2, TileDimensions.Y / 2) + new Vector2(col * TileDimensions.X, row * TileDimensions.Y) + Margins + Position;
    col++;
}

My problem is that it draws the tiles blurry.

If I use this code instead (I delete the first Vector2 from the position):

int col = 0;
int row = 0;
foreach (Tile tile in TileList)
{
    if (col > NumTiles.X) {
        row++;
    }
    tile.Position = new Vector2(col * TileDimensions.X, row * TileDimensions.Y) + Margins + Position;
    col++;
}

It draws them fine.

Images:

LowRes

HighRes

EDIT: I just found that I need to cast the numbers as integers, or the spritebatch does some funky inbetween pixel stuff which happens to blur my image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2024-12-27 05:44:57

我刚刚发现我需要将数字转换为整数,或者 spritebatch 在像素之间做了一些时髦的事情,这恰好模糊了我的图像

I just found that I need to cast the numbers as integers, or the spritebatch does some funky inbetween pixel stuff which happens to blur my image

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文