0

I am trying to enlarge the size of screenshot without losing quality (as possible), but I can not do this. I am processing this picture in another method and filestream stop working. Actually tesseract can not read because of the screenshot's size so I am trying to enlarge the size of screenshot but I can not change the size of screenshot during capturing.

private void button1_Click(object sender, EventArgs e) 
{
    System.Threading.Thread.Sleep(4000); 
    Snapshot().Save("D:\\program_goruntusu.jpg");
    string s = FotoAnaliz();
}

private Bitmap Snapshot()
{
    Bitmap Screenshot = new Bitmap(20, 20);
    Graphics GFX = Graphics.FromImage(Screenshot);
    GFX.CopyFromScreen(1243, 349, 0, 0, new Size(20, 20));
    return Screenshot;
}

private string FotoAnaliz()
{
    FileStream fs = new FileStream("D:\\program_goruntusu.jpg", FileMode.OpenOrCreate);
    //string fotopath = @"D:\\program_goruntusu.jpg";
    Bitmap images = new Bitmap(fs);
    using (var engine = new TesseractEngine(@"./tessdata", "eng"))
    {
        engine.SetVariable("tessedit_char_whitelist", "0123456789");
        // have to load Pix via a bitmap since Pix doesn't support loading a stream.
        using (var image = new Bitmap(images))
        {
            using (var pix = PixConverter.ToPix(image))
            {
                using (var page = engine.Process(pix))
                {
                    sayı = page.GetText();
                    MessageBox.Show(sayı);
                    fs.Close();
                }
            }
        }
    }
    return sayı;
}
Dale K
  • 25,246
  • 15
  • 42
  • 71
vaqol
  • 1
  • There is *no way* to improve the image content resolution simply by enlarging an image. You will need to post-process (sharpen) the image afterwards, but the results might greatly differ. – dymanoid Oct 03 '19 at 21:47
  • Possible duplicate of [How to resize an Image C#](https://stackoverflow.com/questions/1922040/how-to-resize-an-image-c-sharp) –  Oct 03 '19 at 21:56
  • 2
    Step one : __Save as png__ !! - Jpeg is the worst format for crips pixels. Step 2: Understand that you can't add information. You can enlarge without getting fuzzy results (by scaling by integer factors) but you can't create new information! – TaW Oct 03 '19 at 21:58

0 Answers0