private string[] ConvertToMultipleImages(string text) { DrawTextConverter textConvert = new DrawTextConverter(); MemoryStream imageStream = textConvert.DrawText(text); using (Image srcImage = Image.FromStream(imageStream)) { return(ConvertImageToString(SplitImage(srcImage))); } }
public ActionResult GetCustIdBarCode() { DrawTextConverter textConvert = new DrawTextConverter(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path = Path.Combine(path, "test.png"); MemoryStream img = textConvert.DrawText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"); using (Image srcImage = Image.FromStream(img)) { // I'm not sure if the using here will work or not. It might work // to just remove the using block if you have issues. srcImage.Save(path, ImageFormat.Png); using (var streak = new MemoryStream()) { srcImage.Save(streak, ImageFormat.Png); return(File(streak.ToArray(), "image/png")); } } }
public IActionResult GetImage() { DrawTextConverter textConvert = new DrawTextConverter(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); path = Path.Combine(path, "test.png"); MemoryStream img = textConvert.DrawText("first, create a dummy bitmap just to get a graphics object"); using (Image srcImage = Image.FromStream(img)) { //zapisanie głównego srcImage.Save(path, ImageFormat.Png); Image[] imgarray = SplitImage(srcImage); using (var streak = new MemoryStream()) { srcImage.Save(streak, ImageFormat.Png); return(File(streak.ToArray(), "image/png")); } } }