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.
精彩评论