• 13
• 12
• 9
• 10
• 13

Texture.LockRectangle problem...

This topic is 4138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm locking a rectangle on a texture that's 512x512. The rectangle that I want to lock is position = 25,25 and size = 50,50 so I call lock rectangle like this:
Rectangle area = new Rectangle(25,25,50,50);
Array a = tex.LockRectangle(typeof(int), 0, area, LockFlags.None, new int[] { area.Height, area.Width });


The problem I'm getting is that it paints bands rather than the entire rectangle. It seems to lock a region that is within the rectangle but the x and y indexes don't point to the proper pixels. Sometimes if I paint the entire rectangle then it will only paint a band on the top or bottom of the rectangle and sometimes the entire rectangle. Please help, Devin

Share on other sites
How are you writing data to the locked rectangle?

When writing, you need to use the Offset returned by the lock method as the "width of a row". This is because internally, DX might use a surface that's a different width from the area that was locked.

Hope this helps.

Share on other sites
I'm lost. The only thing returned is an array of data. To write to the array I just use Array.SetValue(data, y, x);

Any ideas? Perhaps it's a bug in mdx.

-Devin

Share on other sites
This method has several overloads, half of which have an out parameter that returns the pitch.

Like this:
int pitch;Array a = tex.LockRectangle(typeof(int), 0, area, LockFlags.None, out pitch, new int[] { area.Height, area.Width });
Hope this helps.

Share on other sites
What good is the pitch going to do when it returns an array that is bound to 2 dimensions?

I don't understand how that can be used.

Devin

Share on other sites
What good is the pitch going to do when it returns an array that is bound to 2 dimensions?

I don't understand how that can be used.