Hello
My problem is that I want to export the map into image but probably I don't have permisions to access the pixels of the map. Exactly my error is at "bitmap.Pixels" part of the code where the exception is :
'bitmap.Pixels' threw an exception of type 'System.Security.SecurityException'
This is my code:
WriteableBitmap bitmap = new WriteableBitmap(myMapControl, new TranslateTransform());
EditableImage imageData = new EditableImage(bitmap.PixelWidth, bitmap.PixelHeight);
try
{
for (int y = 0; y < bitmap.PixelHeight; ++y)
{
for (int x = 0; x < bitmap.PixelWidth; ++x)
{
int pixel = bitmap.Pixels[bitmap.PixelWidth * y + x];
imageData.SetPixel(x, y,
(byte)((pixel >> 16) & 0xFF),
(byte)((pixel >> 😎 & 0xFF),
(byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF)
);
}
}
}
catch (System.Security.SecurityException)
{
throw new Exception("Cannot print images from other domains");
}
Is anyone has idea how to solve this.