Refactoring which replaces the Image in the ImageOutput for an ISurface, this makes it possible to save the Surface to any possible file format and even make it possible to pass some additional information in the OutputSettings. (Except reducing the colors, there are no other settings yet)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2376 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-11 14:36:20 +00:00
commit 5541e2e1c7
27 changed files with 191 additions and 290 deletions

View file

@ -138,24 +138,10 @@ namespace GreenshotOCR {
public string DoOCR(ISurface surface) {
string filePath = null;
OutputSettings outputSettings = new OutputSettings(OutputFormat.bmp, 0, true);
// TODO: Add some filter & output settings so the output image is easier to process for the MODI-OCR code
// Also we need to check the size, resize if needed to 130x130 this is the minimum
filePath = ImageOutput.SaveToTmpFile(surface, outputSettings, null);
// Use surface background image, this prevents having a mouse cursor in the way.
Image capturedImage = surface.Image;
if (capturedImage.Width < MIN_WIDTH || capturedImage.Height < MIN_HEIGHT) {
LOG.Debug("Captured image is not big enough for OCR, growing image...");
int newWidth = Math.Max(capturedImage.Width, MIN_WIDTH);
int newHeight = Math.Max(capturedImage.Height, MIN_HEIGHT);
using (Image tmpImage = new Bitmap(newWidth, newHeight, capturedImage.PixelFormat)) {
using (Graphics graphics = Graphics.FromImage(tmpImage)) {
graphics.Clear(Color.White);
graphics.DrawImage(capturedImage, Point.Empty);
}
filePath = ImageOutput.SaveToTmpFile(tmpImage, outputSettings, null);
}
} else {
filePath = ImageOutput.SaveToTmpFile(capturedImage, outputSettings, null);
}
LOG.Debug("Saved tmp file to: " + filePath);
string text = "";