public static Byte[] TranslateImageToBytes(System.Windows.Controls.Image ImageControl) { WriteableBitmap wBitmap = new WriteableBitmap(ImageControl, null); int hgt = wBitmap.PixelHeight; int wdth = wBitmap.PixelWidth; EditableImage ei = new EditableImage(wdth, hgt); for (int y = 0; y < hgt; y++) { for (int x = 0; x < wdth; x++) { int pixel = wBitmap.Pixels[((y * wdth) + x)]; ei.SetPixel(x, y, (byte)((pixel >> 16) & 0xff), (byte)((pixel >> 8) & 0xff), (byte)(pixel & 0xff), (byte)((pixel >> 24) & 0xff)); } } return ei.GetStream().GetAllBytes(); }
public static Byte[] TranslateImageToBytes(System.Windows.Controls.Image ImageControl) { WriteableBitmap wBitmap = new WriteableBitmap(ImageControl, null); int hgt = wBitmap.PixelHeight; int wdth = wBitmap.PixelWidth; EditableImage ei = new EditableImage(wdth, hgt); for (int y = 0; y < hgt; y++) { for (int x = 0; x < wdth; x++) { int pixel = wBitmap.Pixels[((y * wdth) + x)]; ei.SetPixel(x, y, (byte)((pixel >> 16) & 0xff), (byte)((pixel >> 8) & 0xff), (byte)(pixel & 0xff), (byte)((pixel >> 24) & 0xff)); } } return(ei.GetStream().GetAllBytes()); }