My working Project which I code, is created barcode code. And I want to validate the image. As you know that barcode image changes every time but size never change.
So at Ranorex How to covert image to byte array?
Thank you in advanced...
How to convert image to byte array?
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert image to byte array?
Hello espekkaya,
Unfortunately I’m not exactly sure what you want to do. Please provide additional information on how your compare should look like.
Regards,
Robert
Unfortunately I’m not exactly sure what you want to do. Please provide additional information on how your compare should look like.
Regards,
Robert
Re: How to convert image to byte array?
Hello,
Shortly I want to get size of image at my repository. so I compare size of images.
Thank you.
Shortly I want to get size of image at my repository. so I compare size of images.
Thank you.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert image to byte array?
Hello espekkaya,
Unfortunately it’s not possible to retrieve the files size of the screenshot elements since they are stored in the *.rximgres and not separately as bitmap files.
In order to overcome this issue I suggest saving the screenshots as bitmap files to your disk. After that you can access the file via the FileInfo-Class which is provided by the System.IO assembly. The FileInfo-Class provides the FileInfo.Length property which returns the size of the current file in bytes.
For further information concerning the FileInfo-Class, please visit: http://msdn.microsoft.com/en-us/library ... .110).aspx
Regards,
Robert
Unfortunately it’s not possible to retrieve the files size of the screenshot elements since they are stored in the *.rximgres and not separately as bitmap files.
In order to overcome this issue I suggest saving the screenshots as bitmap files to your disk. After that you can access the file via the FileInfo-Class which is provided by the System.IO assembly. The FileInfo-Class provides the FileInfo.Length property which returns the size of the current file in bytes.
For further information concerning the FileInfo-Class, please visit: http://msdn.microsoft.com/en-us/library ... .110).aspx
Regards,
Robert
Re: How to convert image to byte array?
Thank you for your response.
I have an other solution.
Here is my code;
I Hope that it is useful.
I have an other solution.
Here is my code;
Code: Select all
try
{
var webClient = new WebClient();
byte[] imageBytes = webClient.DownloadData(repo.myItemsPath.myItemImage.Src.Trim());
Validate.IsTrue((imageBytes.LongLength == 0) ? false : true);
Report.Success("Control", "Image exists.");
}
catch(Exception ex)
{
Validate.IsTrue(false);
Report.Warn("Control", "Image does not exist.");
}
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to convert image to byte array?
Hello espakkaya,
I'm glad that you found a solution. Thank you for sharing your code.
Regards,
Robert
I'm glad that you found a solution. Thank you for sharing your code.
Regards,
Robert