Skip to content

Commit

Permalink
Fixed small build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
raczeja committed Mar 28, 2019
1 parent 7bc8acb commit 894f8ad
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Objectivity.Test.Automation.Common/Helpers/TakeScreenShot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,29 +166,30 @@ public static string TakeScreenShotOfElement(int iframeLocationX, int iframeLoca

Logger.Debug(CultureInfo.CurrentCulture, "Cutting out screenshot of element locationX:{0} locationY:{1} elementWidth:{2} elementHeight:{3}", locationX, locationY, elementWidth, elementHeight);

var importFile = new Bitmap(filePath);
////Check if new size of image is not bigger than imported.
if (importFile.Size.Height - locationY < elementHeight)
{
elementHeight = importFile.Size.Height - locationY;
}

if (importFile.Size.Width - locationX < elementWidth)
{
elementHeight = importFile.Size.Height - locationX;
}

var image = new Rectangle(locationX, locationY, elementWidth, elementHeight);
string newFilePath;
Bitmap importFile = null;
Bitmap cloneFile;
try
{
importFile = new Bitmap(filePath);
////Check if new size of image is not bigger than imported.
if (importFile.Size.Height - locationY < elementHeight)
{
elementHeight = importFile.Size.Height - locationY;
}

if (importFile.Size.Width - locationX < elementWidth)
{
elementWidth = importFile.Size.Width - locationX;
}

var image = new Rectangle(locationX, locationY, elementWidth, elementHeight);
newFilePath = Path.Combine(folder, screenshotName + ".png");
cloneFile = (Bitmap)importFile.Clone(image, importFile.PixelFormat);
}
finally
{
importFile.Dispose();
importFile?.Dispose();
}

Logger.Debug(CultureInfo.CurrentCulture, "Saving screenshot of element {0}", newFilePath);
Expand Down

0 comments on commit 894f8ad

Please sign in to comment.