Note that there are some explanatory texts on larger screens.

plurals
  1. POHow calcutale GraphicsStream Position of specific pixel on screen?
    primarykey
    data
    text
    <p>How calculate position of specific pixel inside of graphics stream? This stream is screenshot of my primary monitor. Lets say I want position for pixel at: </p> <pre><code>0, 0 0, 10 10, 0 10, 10 </code></pre> <p>Im using DirectX 9 SDK.<br> Here is part of code what Im using(from <a href="http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp" rel="nofollow">this</a> tutorial) to calculate position: </p> <pre><code>const int Bpp = 4; int o = 20; int m = 8; int screenWidthMinusM = Screen.PrimaryScreen.Bounds.Width - m; int screenHeightMinusM = Screen.PrimaryScreen.Bounds.Height - m; int bx = (screenWidthMinusM - m) / 3 + m; int by = (screenHeightMinusM - m) / 3 + m; int bx2 = (screenWidthMinusM - m) * 2 / 3 + m; int by2 = (screenHeightMinusM - m) * 2 / 3 + m; long x, y; long pos; y = m; for (x = m; x &lt; screenWidthMinusM; x += o) { pos = (y * Screen.PrimaryScreen.Bounds.Width + x) * Bpp; if (x &lt; bx) tlPos.Add(pos); else if (x &gt; bx &amp;&amp; x &lt; bx2) tPos.Add(pos); else if (x &gt; bx2) trPos.Add(pos); } </code></pre> <p>but this returns collection with numbers starting about 53 000 to about 7 000 000(from another similar method). After that color is extracted </p> <pre><code>Surface s = sc.CaptureScreen(); GraphicsStream gs = s.LockRectangle(LockFlags.None); byte[] bu = new byte[4]; foreach (long pos in positions) { gs.Position = pos; gs.Read(bu, 0, 4); r += bu[2]; g += bu[1]; b += bu[0]; i++; } </code></pre> <p>I need to make my own collection containing these positions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload