Java纹理png修改 [英] Java texture png modificaiton

查看:115
本文介绍了Java纹理png修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的Java游戏. 我有一些要绘制的png文件,但首先我要对该png进行一些修改.我想取一个png,并删除背景的某些部分并添加一些彩色的线. 对于我的游戏,即时通讯使用libgdx. 我不知道该用什么,所以我可以在Google上搜索并学习. 没什么提示,我应该使用什么功能,太棒了,泰.

P.S.在尝试发布之前,我曾尝试在互联网上进行搜索,但没有找到对我有帮助的内容,可能是idk要搜索的内容.

我从libgdx找到了Pixmap,但是我可以将其删除到后台.有什么建议吗?

Edit2: 我想加载此纹理 需要时乘以(这里没有问题) 并将其某些部分删除到背景,因此它将采用以下形状: 通过使用pixmap,当我在其上绘制背景时,什么也不会发生,因为它是在上面绘制而不是在上面绘制. 我可以做的是使用pixmap绘制要删除的顶部,然后使用外部程序手动将其删除:

解决方案

我认为您可能希望查看蒙版"图像.这里列出了一些方法: https://github.com/mattdesl/lwjgl -basics/wiki/LibGDX-Masking

或者,您可以使用创建一个网格来对地面"(带有凹凸)进行编码,然后对其进行纹理处理. OpenGL会截断网格的边缘.尝试:使用libgdx绘制带纹理的多边形

另一种方法是只在全屏上绘制污垢纹理,然后在其上绘制背景".您将需要使背景"图像中的像素透明,以便污垢能够透过.无论您使用什么像素编辑器都应该能够做到这一点.另外,当您将图像加载为像素图时,请选择一种关键"颜色并将这些像素转换为透明像素.

I'm trying to make a simple java game. I have some png file that i want to draw, but first i want to make some modification on that png. I would like to take a png, and delete to background some parts of it and add some colored lines.. For my game im using libgdx. I dont know what to use for this, so i can search on google about it and learn. Few hints, about what functions i should use could be awesome, Ty.

P.S. I tryed to search on internet before post here, but i didnt find something that could help me, probably idk what to search.v

Edit: I found Pixmap from libgdx, but i can delete to background. Any advices ?

Edit2: i want to load this texture multiplicate when needed (no problem here) and delete some parts of it, to background, so it will take this shape: by using pixmap, when im drawing background over it, nothing is happen, because its draw over, not instead of. What i could make, was using pixmap to draw the top part, that i want to delete, and manualy delete it using external programs:

解决方案

I think you might want to look at a "mask" image. There are some approaches listed here: https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Masking

Alternatively, you could use create a mesh that encodes the "ground" (with the bump) and then texture it. OpenGL would take care of truncating the edge of the mesh. Try: Drawing textured polygons with libgdx

Another approach is to just draw the dirt texture on the full screen, and then draw the "background" over it. You will need to make pixels in the "background" image transparent so the dirt will show through. Whatever pixel editor you are using should be able to do that. Alternatively, pick a "key" color and convert those pixels to transparent when you load the image as a pixmap.

这篇关于Java纹理png修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆