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
Generic Error when saving an image
Re: Generic Error when saving an image
Hi,
Have you tried to save the image with hardcoded filename and path? Simply, try to save it to c:\temp\test.bmp If the error still occurs, then the problem is most probably somewhere else?
Have you tried to save the image with hardcoded filename and path? Simply, try to save it to c:\temp\test.bmp If the error still occurs, then the problem is most probably somewhere else?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
- Posts: 34
- Joined: Mon Mar 19, 2018 10:02 am
Re: Generic Error when saving an image
Hi,
thank you for the suggestion. You are right the error is somwhere else I have just tried your proposal. :S damn..
thank you for the suggestion. You are right the error is somwhere else I have just tried your proposal. :S damn..
Re: Generic Error when saving an image
Too bad. At least you now know the problem is somewhere else Have you checked this post?...
https://stackoverflow.com/questions/155 ... g-an-image
https://stackoverflow.com/questions/155 ... g-an-image
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
- Posts: 34
- Joined: Mon Mar 19, 2018 10:02 am
Re: Generic Error when saving an image
Thanks for the link but I have discovered the reason why it didn´t want to save. Since my traversing algorithm was taking text values from GUI elemnts including the date as well which has format :dd/mm/yyyy this forward slashes were casuing the error. So i have just added : e.GetAttributeValueText("Text").Replace("/","_").Replace(":","_")
Thank you for the help
Thank you for the help