alinder
13 years agoContributor
Comparing alpha channel for Picture.Compare
I have encountered difficulty using .Compare( ) on Picture objects containing icons from my application under test.
Icons in a part of the application are drawn from images that appear to be all black pixels, with alpha channel per-pixel transparency transforming them into various grayscale renderings.
When I use TestComplete to compare two images, it is not taking the transparencies into account correctly, and images that appear wildly different are being recognized as identical. Attached is a code snippet to demonstrate, with two attached images to place in "c:\temp".
For the moment I have found a workaround by editing the image I use as a baseline and flattening it to a white background, but I worry about coverage issues on other images in my testing that have not required such detailed attention (extracting the icons from the containing object required some custom handling).
Icons in a part of the application are drawn from images that appear to be all black pixels, with alpha channel per-pixel transparency transforming them into various grayscale renderings.
When I use TestComplete to compare two images, it is not taking the transparencies into account correctly, and images that appear wildly different are being recognized as identical. Attached is a code snippet to demonstrate, with two attached images to place in "c:\temp".
Sub TestPicAlpha
Dim pic1, pic2
Set pic1 = Utils.Picture
Set pic2 = Utils.Picture
Call pic1.LoadFromFile("c:\temp\test1.png")
Call pic2.LoadFromFile("c:\temp\test2.png")
Log.Message(pic1.Compare(pic2,False,0,False,0))
End Sub
For the moment I have found a workaround by editing the image I use as a baseline and flattening it to a white background, but I worry about coverage issues on other images in my testing that have not required such detailed attention (extracting the icons from the containing object required some custom handling).