Note that there are some explanatory texts on larger screens.

plurals
  1. POWriteableBitmap failing badly, pixel array very inaccurate
    primarykey
    data
    text
    <p>I have tried, literally for hours, and I have not been able to budge this problem.</p> <p>I have a UserControl, that is 800x369, and it contains, simply, a path that forms a worldmap. I put this on a landscape page, then I render it into a WriteableBitmap. I then run a conversion to turn the 1d Pixels array into a 2d array of integers. Then, to check the conversion, I wire up the custom control's click command to use the Point.X and Point.Y relative to the custom control in the newly created array. My logic is thus:</p> <pre><code>wb = new WriteableBitmap(worldMap, new TranslateTransform()); wb.Invalidate(); intTest = wb.Pixels.To2DArray(wb.PixelWidth); </code></pre> <p>My conversion logic is as such:</p> <pre><code>public static int[,] To2DArray(this int[] arr,int rowLength) { int[,] output = new int[rowLength, arr.Length / rowLength]; if (arr.Length % rowLength != 0) throw new IndexOutOfRangeException(); for (int i = 0; i &lt; arr.Length; i++) { output[i % rowLength, i / rowLength] = arr[i]; } return output; } </code></pre> <p>Now, when I do the checking, I get completely and utterly strange results: apparently all pixels are either at values of -1 or 0, and these values are <strong><em>completely independent</em></strong> of the original colours.</p> <p>Just for posterity: here's my checking code:</p> <pre><code>private void Check(object sender, MouseButtonEventArgs e) { Point click = e.GetPosition(worldMap); ChangeNotification(intTest[(int)click.X,(int)click.Y].ToString()); } </code></pre> <p>The result show absolutely no correlation to the path that the WriteableBitmap has rendered into it. The path has a fill of solid white.</p> <p>What the heck is going on? I've tried for hours with no luck. Please, this is the major problem stopping me from submitting my first WP7 app. Any guidance?</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.
 

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