rushikesh
9 years agoContributor
How to skip certain code if image does not exist in below code.
How to skip certain code if image does not exist in below code. My code is var baseImage = Utils.Picture var outputImage = Utils.Picture baseImage.LoadFromFile(baseImagePath) outputImag...
- 9 years ago
EDIT: DOH! I got my booleans backwards... I've edited the below code a bit... removed the not (!) so that we check for TRUE AND TRUE in the if logic... my bad
The LoadFromFile method returns a boolean value to indicate success or failure to load the image. So, you need to add some logic around those calls to detect whether or not the method. This might not be optimal code, but I'd try something like
var baseImage = Utils.Picture var outputImage = Utils.Picture if ((baseImage.LoadFromFile(baseImagePath) && (outputImage.LoadFromFile(outputImagePath)) { diffImage = outputImage.Difference(baseImage); if (diffImage == null) Log.Checkpoint('Image comparision passed ); else { Log.Error('Image comparision failed) diffImage.SaveToFile(diffImagePath) } } else { Log.Error('One of the images did not successfully load'); }