The resizing didn't work, after the resizing was fixed the OCR didn't work and I had to change to resize the canvas... now it seems to be working again.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2410 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-01-05 23:55:36 +00:00
commit 42011d2588
2 changed files with 21 additions and 3 deletions

View file

@ -147,8 +147,16 @@ namespace GreenshotOCR {
// Also we need to check the size, resize if needed to 130x130 this is the minimum // Also we need to check the size, resize if needed to 130x130 this is the minimum
if (surface.Image.Width < MIN_WIDTH || surface.Image.Height < MIN_HEIGHT) { if (surface.Image.Width < MIN_WIDTH || surface.Image.Height < MIN_HEIGHT) {
IEffect resizeEffect = new ResizeEffect(Math.Max(surface.Image.Width, MIN_WIDTH), Math.Max(surface.Image.Height, MIN_HEIGHT), true); int addedWidth = MIN_WIDTH - surface.Image.Width;
outputSettings.Effects.Add(resizeEffect); if (addedWidth < 0) {
addedWidth = 0;
}
int addedHeight = MIN_HEIGHT - surface.Image.Height;
if (addedHeight < 0) {
addedHeight = 0;
}
IEffect effect = new ResizeCanvasEffect(addedWidth / 2, addedWidth / 2, addedHeight / 2, addedHeight / 2);
outputSettings.Effects.Add(effect);
} }
filePath = ImageOutput.SaveToTmpFile(surface, outputSettings, null); filePath = ImageOutput.SaveToTmpFile(surface, outputSettings, null);

View file

@ -1321,7 +1321,17 @@ namespace GreenshotPlugin.Core {
nPercentW = ((float)newWidth / (float)sourceImage.Width); nPercentW = ((float)newWidth / (float)sourceImage.Width);
nPercentH = ((float)newHeight / (float)sourceImage.Height); nPercentH = ((float)newHeight / (float)sourceImage.Height);
if (maintainAspectRatio) { if (maintainAspectRatio) {
if (nPercentH != 0 && nPercentH < nPercentW) { if (nPercentW == 1) {
nPercentW = nPercentH;
if (canvasUseNewSize) {
destX = Math.Max(0, System.Convert.ToInt32((newWidth - (sourceImage.Width * nPercentW)) / 2));
}
} else if (nPercentH == 1) {
nPercentH = nPercentW;
if (canvasUseNewSize) {
destY = Math.Max(0, System.Convert.ToInt32((newHeight - (sourceImage.Height * nPercentH)) / 2));
}
} else if (nPercentH != 0 && nPercentH < nPercentW) {
nPercentW = nPercentH; nPercentW = nPercentH;
if (canvasUseNewSize) { if (canvasUseNewSize) {
destX = Math.Max(0, System.Convert.ToInt32((newWidth - (sourceImage.Width * nPercentW)) / 2)); destX = Math.Max(0, System.Convert.ToInt32((newWidth - (sourceImage.Width * nPercentW)) / 2));