bit array to d3d texture surface
Is it possible to create a blank texture, get its surface, lock it, and copy bits to it? Specifically, when I lock it, do I get an array which is sized n^2, every 4 elements being rgba?
When you lock a surface, you get a pointer to it's first scanline of data. The pitch (AKA memory width AKA memory distance between lines) of a scanline may vary, but you get that also when you lock the surface.
To fill the texture, loop through the scanlines (count of which is the surface height), and multiply the current scanline number by the pitch to obtain pointers for each individual scanline. In the inner loop, go through each pixel of the scanline - the amount of valid pixels is exactly equal to the surface's pixel width.
The type of data is determined from the texture format - you don't automatically get ARGB32 values, unless your surface format happens to actually be ARGB32.
To fill the texture, loop through the scanlines (count of which is the surface height), and multiply the current scanline number by the pitch to obtain pointers for each individual scanline. In the inner loop, go through each pixel of the scanline - the amount of valid pixels is exactly equal to the surface's pixel width.
The type of data is determined from the texture format - you don't automatically get ARGB32 values, unless your surface format happens to actually be ARGB32.
Check out this kbase article. It outlines locking a surface, and then reading or writing to it's pixels.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement