[英]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. 我有一个texture2D,我想获得指定像素的颜色。 Do something with it and put a new color in an other texture2D. 用它做一些事情并在另一个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# 它需要在C#中
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. 当我试图获得像素的颜色时,颜色的Alpha值为0.这意味着颜色将是完全透明的。 To solve it I just needed to change the Alpha value to 255. 要解决它我只需要将Alpha值更改为255。
I think that this happened because I am using an jpg file. 我认为这是因为我使用的是jpg文件。 Jpg file's do not support Alpha values. Jpg文件不支持Alpha值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.