3

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#

Aaron de Windt
  • 16,794
  • 13
  • 47
  • 62
  • 2
    Isn't that what pixel shader's are for? Why wouldn't you want one? – Nate Feb 16 '10 at 20:01
  • How big are your textures? setting data onto a texture isn't too bad but getting data from a texture can be very slow... – Martin Feb 16 '10 at 23:21
  • I am trying to do a 2d water animation. Go here:http://freespace.virgin.net/hugo.elias/graphics/x_water.htm. The textures are not very big. I think that they are 400 x 300. I will keep experimenting to see how big I can make them. – Aaron de Windt Feb 17 '10 at 00:30

2 Answers2

2

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

David Brown
  • 35,411
  • 11
  • 83
  • 132
0

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.

Aaron de Windt
  • 16,794
  • 13
  • 47
  • 62