none
IronOCR not reading images created from MemoryStream. RRS feed

  • Question

  • I am using the IronOCR to read an image to text, however, it is not reading the file created from my MemoryStream():

    using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
            {
    
                using (Graphics g = Graphics.FromImage(bitmap))
                {
    
                    g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
    
                    if (showCursor)
                    {
                        Rectangle cursorBounds = new Rectangle(curPos, curSize);
                        Cursors.Default.Draw(g, cursorBounds);
                    }
    
    
    
                }
    
                using (MemoryStream ms = new MemoryStream())
                {
    
                    Image img = (Image)bitmap;
    
                    img.Save(ms, ImageFormat.Jpeg);
                    Bitmap bm = new Bitmap(ms);
                    Clipboard.SetImage(bm);
    
                    if (!File.Exists(@"C:\Users\Cowboy\Desktop\Images\mstemp.jpg"))
                    {
                        img.Save(@"C:\Users\Cowboy\Desktop\Images\mstemp.jpg");                        
                    }
                    else
                    {
                        File.Delete(@"C:\Users\Cowboy\Desktop\Images\mstemp.jpg");
                        img.Save(@"C:\Users\Cowboy\Desktop\Images\mstemp.jpg");
                    }
    
                    ms.Dispose();
                }
    
            }

    However, if I use LightShot to take a screen shot, IronOCR will read it perfectly.


    Careful lieutenant, in time, you could develop a tumor.

    • Moved by CoolDadTx Friday, February 9, 2018 3:54 PM Third party product
    Friday, February 9, 2018 3:09 AM

All replies

  • Sounds like an IronOCR problem. What is it about the C# language that you need help with?


    Sam Hobbs
    SimpleSamples.Info

    Friday, February 9, 2018 3:45 AM
  • These forums are for MS products only. Please post questions related to third party products in their forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, February 9, 2018 3:54 PM
  • I understand IronOCR is not within the scope, however, if IronOCR is able to read screenshot created by other applications like green shot, light shot, and print screen (a MS built in function), then the code I am using is in fact excluding some important raw data that would otherwise prevent the IronOCR functionality from doing its job. Nothing is wrong with IronOCR, its how the raw data stream/bitmap of my images are preventing the programs like IronOCR or Tesseract from reading my screenshots.

    So yes, I believe my inquiry is within the scope of this discussion.

    Careful lieutenant, in time, you could develop a tumor.

    Friday, February 9, 2018 10:43 PM
  • You need to have specifics about the problem. 


    Sam Hobbs
    SimpleSamples.Info

    Friday, February 9, 2018 11:19 PM