LibGDX:为什么我的黑白图片变得透明?

编程入门 行业动态 更新时间:2024-10-25 00:28:52
本文介绍了LibGDX:为什么我的黑白图片变得透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我还有另一个LibGDX问题(-_-).我有这样的黑白图像:

I have another LibGDX Problem (-_-). I have an black/white image like this:

现在,我尝试在PlayScreen中将此图片用作背景图片:

Now I try to use this image as my background image in my PlayScreen:

PlayScreen类:

Class PlayScreen:

(...) Texture background; (...) background = new Texture("grid.jpg"); (...) gameHandler.getBatch().begin(); gameHandler.getBatch().draw(background,0,0,Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gameHandler.getBatch().end(); (...)

GameHandler类:

class GameHandler:

(...) Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); this.getScreen().render(Gdx.graphics.getDeltaTime()); (...)

使用此代码,我会遵循(错误的比例是因为视口,但这没关系):

Using this code I get following(wrong scale is because viewport, but that doesn´t matter):

如何保留真实图像的颜色?

How can I keep the colors of the real image?

希望您能帮助我! 〜亨利

Hope you can help me! ~Henri

推荐答案

您的图像已损坏.

尝试一下:

知道我将路径更改为

1.png

更多推荐

LibGDX:为什么我的黑白图片变得透明?

本文发布于:2023-10-23 00:13:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519164.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:透明   黑白图片   LibGDX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!