ajitjaiswal50 / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

Change Bit Depth of screen shot #166

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Operating system :
.Net Framework version :
Office Version :
SeleniumWrapper version :

What is your issue ?
How to save the Screen shots in 24 Bit format?

Original issue reported on code.google.com by v.moort...@gmail.com on 21 Jul 2015 at 11:53

GoogleCodeExporter commented 8 years ago
May I ask what is the reason behind it?
The current output is always a PNG 32bit but the alpha channel is not used.
So the gain would be insignificant from a conversion to a PNG 24bit.

Original comment by florentbr on 22 Jul 2015 at 4:17

GoogleCodeExporter commented 8 years ago
Thank you for your quick response
VBA userform not accepting 32Bit images, it will show as “Invalid Picture”. 
Only 24 Bit images as allowed.
With MS paint we can make the image from 32 Bit to 24 Bit. It will be great  if 
we have option to save the screen shot in 24 Bit directly.

Code:
selenium.findElementByXPath(“xxx").getScreenshot.SaveAs ("C:\Screen_Shot\" & 
ID & ".jpg")

Original comment by v.moort...@gmail.com on 22 Jul 2015 at 4:47

GoogleCodeExporter commented 8 years ago
Actually it is the PNG format that is not supported by the Form.
I've added support to other format such as bmp, gif, jpg:
    driver.TakeScreenShoot().SaveAs "c:\temp\img.bmp"
    driver.TakeScreenShoot().SaveAs "c:\temp\img.gif"
    driver.TakeScreenShoot().SaveAs "c:\temp\img.jpg"
    pictObj.Picture = LoadPicture("c:\temp\img.bmp")
    Me.Repaint

And I've also added a method to get the native image:
    pictObj.Picture = driver.TakeScreenShoot().GetPicture()
    Me.Repaint

It will be available in release 2.0.3.0
FYI, the API has slightly changed since version 1.0.x.x and the project
project has moved to GitHub:
http://florentbr.github.io/SeleniumBasic/

Original comment by florentbr on 22 Jul 2015 at 5:10