Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rectangle argument in surface.LockRectangle(Rectangle, LockFlags) is faulty or do I not understand it?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Syme   Members   -  Reputation: 121

Like
0Likes
Like

Posted 12 April 2013 - 12:40 PM

Hi all,

First, I know next to nothing about DirectX so thank you in advance for the patience. I want to access RGB pixel data of a rectangular sub-area of the screen. I can successfully access the data for the full screen like this:

var surface = Surface.CreateOffscreenPlain(myDevice, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Format.A8R8G8B8, Pool.Scratch);
myDevice.GetFrontBufferData(0, surface);
var dataRectangle = surface.LockRectangle(LockFlags.None);
DataStream rgbStream = dataRectangle.Data;

My understanding is that to get the byte stream of a 256*256 px square based in the top left the third line needs to be replaced by:

var dataRectangle = surface.LockRectangle(new Rectangle(0, 0, 256, 256), LockFlags.None);

The resulting data stream is however identical to the last byte to the one produced when there was no Rectangle argument. I've tested it with multiple values and the area of the rectangle never changed the stream in any way (the anchoring point of the rectangle on the other hand did).

Am I not understanding the method properly? Thanks for your help.

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 6324

Like
0Likes
Like

Posted 12 April 2013 - 04:47 PM

The rectangle locked just modifies the dirty region of a texture or surface; i.e. the region that needs to be written back to the GPU after you unlock.  What you're seeing is normal enough; you can test and confirm this by locking a small rect, writing something like all-white to the texture, unlocking and seeing what part of the texture was actually updated when you use it next.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS