Generic Error when saving an image
Posted: Tue Jun 05, 2018 8:01 am
Hi,
i am having diffuculties with the following error: Unexpected exception occurred: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at TraversGUI.TraverseAlgorithm.GetAndStoreTextPictureAndOCRFromElement(Element e, String path) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\TraverseAlgorithm.cs:line 243
at TraversGUI.TraverseAlgorithm.Traverse(String path) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\TraverseAlgorithm.cs:line 111
at TraversGUI.Program.Main(String[] args) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\Program.cs:line 40
I have been looking at these particular lines of code and I did debuging, my first assumption was that I have problem when saving the element by its name. (In the case of the date-time I had to do string formating which I did, but still error ocures).
The code where the error ocures:
Bitmap image = Imaging.CaptureImage(e);
string imagePathAndName = currentResultFolder+ path + "_" + e.GetAttributeValueText("Text").Replace(":","")+".bmp";
if(image.Size.Height>=500 || image.Size.Width>=500) {
if(image.Size.Height>image.Size.Width) {
image = resizeImage(image,new Size(((int)(450*image.Width/image.Height)),450));
}else{
image = resizeImage(image,new Size(450,((int)(450*image.Height/image.Width))));
}
}
image.Save(imagePathAndName);
Does anyone have Idea what could cause this error and how to solve it? Thanks
i am having diffuculties with the following error: Unexpected exception occurred: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at TraversGUI.TraverseAlgorithm.GetAndStoreTextPictureAndOCRFromElement(Element e, String path) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\TraverseAlgorithm.cs:line 243
at TraversGUI.TraverseAlgorithm.Traverse(String path) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\TraverseAlgorithm.cs:line 111
at TraversGUI.Program.Main(String[] args) in c:\Users\xfsqa4\Documents\Ranorex\RanorexStudio Projects\TraversGUI\TraversGUI\Program.cs:line 40
I have been looking at these particular lines of code and I did debuging, my first assumption was that I have problem when saving the element by its name. (In the case of the date-time I had to do string formating which I did, but still error ocures).
The code where the error ocures:
Bitmap image = Imaging.CaptureImage(e);
string imagePathAndName = currentResultFolder+ path + "_" + e.GetAttributeValueText("Text").Replace(":","")+".bmp";
if(image.Size.Height>=500 || image.Size.Width>=500) {
if(image.Size.Height>image.Size.Width) {
image = resizeImage(image,new Size(((int)(450*image.Width/image.Height)),450));
}else{
image = resizeImage(image,new Size(450,((int)(450*image.Height/image.Width))));
}
}
image.Save(imagePathAndName);
Does anyone have Idea what could cause this error and how to solve it? Thanks