<legend id='vL3oW'><style id='vL3oW'><dir id='vL3oW'><q id='vL3oW'></q></dir></style></legend>
      <i id='vL3oW'><tr id='vL3oW'><dt id='vL3oW'><q id='vL3oW'><span id='vL3oW'><b id='vL3oW'><form id='vL3oW'><ins id='vL3oW'></ins><ul id='vL3oW'></ul><sub id='vL3oW'></sub></form><legend id='vL3oW'></legend><bdo id='vL3oW'><pre id='vL3oW'><center id='vL3oW'></center></pre></bdo></b><th id='vL3oW'></th></span></q></dt></tr></i><div id='vL3oW'><tfoot id='vL3oW'></tfoot><dl id='vL3oW'><fieldset id='vL3oW'></fieldset></dl></div>

      <tfoot id='vL3oW'></tfoot>

      <small id='vL3oW'></small><noframes id='vL3oW'>

      • <bdo id='vL3oW'></bdo><ul id='vL3oW'></ul>

      LibGdx 纹理绘制为与 #getTextureData 给出的相反

      时间:2023-05-18

            <tbody id='o9I7r'></tbody>

            <small id='o9I7r'></small><noframes id='o9I7r'>

            <i id='o9I7r'><tr id='o9I7r'><dt id='o9I7r'><q id='o9I7r'><span id='o9I7r'><b id='o9I7r'><form id='o9I7r'><ins id='o9I7r'></ins><ul id='o9I7r'></ul><sub id='o9I7r'></sub></form><legend id='o9I7r'></legend><bdo id='o9I7r'><pre id='o9I7r'><center id='o9I7r'></center></pre></bdo></b><th id='o9I7r'></th></span></q></dt></tr></i><div id='o9I7r'><tfoot id='o9I7r'></tfoot><dl id='o9I7r'><fieldset id='o9I7r'></fieldset></dl></div>
          • <tfoot id='o9I7r'></tfoot>

                <bdo id='o9I7r'></bdo><ul id='o9I7r'></ul>
              • <legend id='o9I7r'><style id='o9I7r'><dir id='o9I7r'><q id='o9I7r'></q></dir></style></legend>
                本文介绍了LibGdx 纹理绘制为与 #getTextureData 给出的相反的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我一直在尝试解决在我的 libgdx 桌面程序上正确显示纹理时遇到的这个问题.

                I've been trying to resolve this issue I have been having with displaying a texture correctly on my libgdx desktop program.

                我有一个正交相机,当我设置为:

                I have an Orthographic camera with which when I set as:

                camera.setOrtho(false);
                

                我得到这张图片:

                当我将其设置为:

                camera.setOrtho(true);
                

                我得到这张图片:

                红色图像是用 SpriteBatch 绘制的:

                The red image is drawn with a SpriteBatch:

                batch.draw(texture, x, y, width, height);
                

                而白色图像是从根据 alpha 值是否为 1 绘制的各个点绘制的.

                While the white image is drawn from individual points plotted based on if their alpha value was 1.

                TextureData td = texture.getTextureData();
                td.prepare;
                Pixmap map = td.consumePixmap();
                for (int i = 0; i < map.getWidth(); i++)
                            for (int j = 0; j < map.getHeight(); j++)
                                if (new Color(map.getPixel(i, j)).a == 1)
                                    points.add(new Point(i, j));
                

                上面是用于获取所有不透明像素的代码.它们显示为白色图像,似乎与原始纹理相反.

                Above is the code used to get all the non-transparent pixels. They are displayed as the white image, and seem to be the inverse of the original texture.

                但是,绘制的点和图像本身始终是彼此的倒数.

                However, the points plotted and the image itself is always an inverse of one another.

                有没有办法解决这个问题?

                Is there any way of resolving this issue?

                谢谢.

                PS:我尝试了多种方法来尝试解决此问题:

                PS: I've tried multiple ways of trying to fix this:

                • 使用 Sprite 并翻转它们
                • 使用 TextureRegions 并翻转它们

                似乎没有任何效果.

                推荐答案

                是的,这很讨厌,Libgdx 与它的坐标系不一致.就像 font.draw() 从上向下绘制.改变你在循环内绘制/绘图的迭代方式,基本上你必须手动翻转它.因此,当 j == 0 时,y 将成为最高值,如果 j == map.getHeight y 将成为最低值.然后在这些值内线性插值.如果您在循环中显示了什么,我可以提供更多帮助.

                Yes this is very anoying, Libgdx is not consistent with it's coordinate system. Like font.draw() draws from top downward. Alter the way you iterate over you draw/plot inside your loop, basically you have to flip it manually. So when j == 0 then y would become the highest value and if j == map.getHeight y would become the lowest value. Then interpolate linearly within these values. If you shown whats inside your loop I could help out a bit more.

                这篇关于LibGdx 纹理绘制为与 #getTextureData 给出的相反的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Libgdx 1.3.0 不构建 eclipse 文件 下一篇:java- libgdx build.gradle 与 AdMob 不同

                相关文章

                最新文章

                <legend id='fl5gY'><style id='fl5gY'><dir id='fl5gY'><q id='fl5gY'></q></dir></style></legend>

              • <tfoot id='fl5gY'></tfoot>

                1. <small id='fl5gY'></small><noframes id='fl5gY'>

                  <i id='fl5gY'><tr id='fl5gY'><dt id='fl5gY'><q id='fl5gY'><span id='fl5gY'><b id='fl5gY'><form id='fl5gY'><ins id='fl5gY'></ins><ul id='fl5gY'></ul><sub id='fl5gY'></sub></form><legend id='fl5gY'></legend><bdo id='fl5gY'><pre id='fl5gY'><center id='fl5gY'></center></pre></bdo></b><th id='fl5gY'></th></span></q></dt></tr></i><div id='fl5gY'><tfoot id='fl5gY'></tfoot><dl id='fl5gY'><fieldset id='fl5gY'></fieldset></dl></div>

                  • <bdo id='fl5gY'></bdo><ul id='fl5gY'></ul>