Cleanup of unneeded code: Removed a unused property from the OAuthLoginForm and removed the using "imageforexport" as we only want the "background" image of the surface for our OCR.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2085 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-23 13:59:05 +00:00
commit f4f3a77e55
2 changed files with 14 additions and 21 deletions

View file

@ -140,23 +140,23 @@ namespace GreenshotOCR {
private const int MIN_HEIGHT = 130;
public string DoOCR(ISurface surface) {
string filePath = null;
OutputSettings outputSettings = new OutputSettings(OutputFormat.bmp);
OutputSettings outputSettings = new OutputSettings(OutputFormat.bmp, 0, true);
using (Image capturedImage = surface.GetImageForExport()) {
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 = host.SaveToTmpFile(tmpImage, 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);
}
} else {
filePath = host.SaveToTmpFile(capturedImage, outputSettings, null);
filePath = host.SaveToTmpFile(tmpImage, outputSettings, null);
}
} else {
filePath = host.SaveToTmpFile(capturedImage, outputSettings, null);
}
LOG.Debug("Saved tmp file to: " + filePath);