public ActionResult CreateEmbroidery(string img, int coefficient, int cellsCount, string colors, string symbols, string symbolColor, bool grid) { Color[] palette = this.ParseFromStringColors(colors); Color color = this.ParseFromStringColors(symbolColor).First<Color>(); char[] chArray = null; if (symbols != "") { chArray = this.ParseFromStringSymbols(symbols); } byte[] buffer = Convert.FromBase64String(img.Substring(img.IndexOf(',') + 1)); Bitmap image = null; using (MemoryStream stream = new MemoryStream(buffer)) { Bitmap bitmap2 = new Bitmap(stream); image = new Bitmap(bitmap2.Width, bitmap2.Height); for (int i = 0; i < bitmap2.Height; i++) { for (int j = 0; j < bitmap2.Width; j++) { image.SetPixel(j, i, bitmap2.GetPixel(j, i)); } } } EmbroideryCreatorServiceClient client = new EmbroideryCreatorServiceClient(); GridType none = GridType.None; if (grid) { none = GridType.SolidLine; } Bitmap bitmap3 = client.GetEmbroidery(image, coefficient, cellsCount, palette, chArray, color, none); using (MemoryStream stream2 = new MemoryStream()) { bitmap3.Save(stream2, ImageFormat.Jpeg); buffer = stream2.ToArray(); } string str2 = Convert.ToBase64String(buffer); JsonResult result = base.Json(new { imageString = str2 }, JsonRequestBehavior.AllowGet); result.MaxJsonLength = 0x7fffffff; return result; }