private void doWork(object o) { void ScaleTo300DPI(int imgId) { float vertical = GdImg.GetVerticalResolution(imgId); float newval = (300F / vertical) * 100; GdImg.Scale(imgId, newval, InterpolationMode.HighQualityBicubic); } WorkData data = o as WorkData; lock (dwlock) { int hbitmap = data.Blob.GetHbitmap().ToInt32(); int id = GdImg.CreateGdPictureImageFromHBitmap(hbitmap); bool success = blobFactory.TryGetBlob(id, out ISpecial blob); if (success) { Debug.WriteLine(blob.BlobType); GdImg.SetColorRemap(id, blob.RemapTable); if (blob.BlobType == SpecialType.Wind) { GdImg.SaveAsPNG(id, $".\\{Guid.NewGuid().ToString()}.png"); } } ScaleTo300DPI(id); GdOcr.SetImage(id); string ocrId = GdOcr.RunOCR(); string text = GdOcr.GetOCRResultText(ocrId); GdOcr.ReleaseOCRResult(ocrId); GdImg.ReleaseGdPictureImage(id); RaiseRecognizedText(text); } }