I tried literally for hours, and I was not able to move this problem.
I have a UserControl, i.e. 800x369, and it just contains a path that forms a map of the world. I put this on the landscape page, then I turn it into a WriteableBitmap. Then I start the conversion to turn an array of 1d pixels into a 2d array of integers. Then, to test the conversion, I hook up a user click control command to use Point.X and Point.Y relative to the custom control in the newly created array. My logic is this:
wb = new WriteableBitmap(worldMap, new TranslateTransform());
wb.Invalidate();
intTest = wb.Pixels.To2DArray(wb.PixelWidth);
My conversion logic is this:
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 < arr.Length; i++)
{
output[i % rowLength, i / rowLength] = arr[i];
}
return output;
}
, , : , -1 0, .
: :
private void Check(object sender, MouseButtonEventArgs e)
{
Point click = e.GetPosition(worldMap);
ChangeNotification(intTest[(int)click.X,(int)click.Y].ToString());
}
, WriteableBitmap. .
? . , , WP7. ?