Texture.LockRectangle problem...

Started by
4 comments, last by devronious 17 years, 4 months ago
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
Advertisement
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.
Sirob Yes.» - status: Work-O-Rama.
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
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.
Sirob Yes.» - status: Work-O-Rama.
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.

Thanks for your help,

Devin
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.

Thanks for your help,

Devin

This topic is closed to new replies.

Advertisement