开发者

How can I get and set pixel data in XNA?

I have a texture2D where I want to get the color of a specified pi开发者_运维知识库xel. Do something with it and put a new color in an other texture2D.

I will need to do this with all the pixels in the texture. How can I do this.

No pixel shader's please. It need to be in C#


The Texture2D class contains the GetData and SetData methods that should do exactly what you want.


I found my problem.

When I was trying to get the color of a pixel the Alpha value of the color was 0. This means that the color would be completely transparent. To solve it I just needed to change the Alpha value to 255.

I think that this happened because I am using an jpg file. Jpg file's do not support Alpha values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜