简体   繁体   中英

How can I get and set pixel data in XNA?

I have a texture2D where I want to get the color of a specified pixel. 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#

Texture2D类包含GetDataSetData方法,它们应该完全符合您的要求。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM