How do I set a pixel color in a texture using ManagedDX?
Hey guys, I need to set a specific pixel in a texture to a custom color, for doing that I made a Bitmap and I always set the pixel in the bitmap, then I recreate the texture from the bitmap. Doing that is very time consuming, is th开发者_JAVA百科ere any way to modify the pixel directly in the texture?
Yeah you should be able to do it by using the Texture.LockRectangle function. You then need to seek to the correct pixel which will be addressable by jumping to ((y * pitch) + (x * bytesPerPixel)) in the stream. The you write your new pixel and call Texture.UnlockRectangle.
精彩评论