I used WriteableBitmap to take the screenshot of the Image and convert that into Base64 string using FJCore. Due to Domain Issues with WriteableBitmap I am not able to read Pixels from WriteableBitmap.
getting the following Security error:
"WriteableBitmap has protected content. Pixel access is not allowed."
Method Used to convert WritableBitmap to base64string:
public static string ConvertImagetoString(WriteableBitmap bitmap)
{
int width = bitmap.PixelWidth;
int height = bitmap.PixelHeight;
int bands = 3;
byte[][,] raster = new byte[bands][,];
for (int i = 0; i < bands; i++)
{
raster = new byte[width, height];
}
int[] bitpixes = bitmap.Pixels.ToArray();
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
int pixel = bitpixes[width * row + column];
raster[0][column, row] = (byte)(pixel >> 16);
raster[1][column, row] = (byte)(pixel >> 8);
raster[2][column, row] = (byte)pixel;
}
}
ColorModel model = new ColorModel { colorspace = FluxJpeg.Core.ColorSpace.RGB };
FluxJpeg.Core.Image img = new FluxJpeg.Core.Image(model, raster);
MemoryStream stream = new MemoryStream();
JpegEncoder encoder = new JpegEncoder(img, 90, stream);
encoder.Encode();
stream.Seek(0, SeekOrigin.Begin);
byte[] binaryData = new Byte[stream.Length];
long bytesRead = stream.Read(binaryData, 0, (int)stream.Length);
string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length);
return base64String;
}
Function call:
WriteableBitmap redlinescreenshot = new WriteableBitmap(this.TheMap, new TranslateTransform());
string base64String = ConvertImagetoString(redlinescreenshot);
Any help Appreciated...Urgent!!!! Thanks