34 const wxSize imageSize = aImage.GetSize();
36 if( imageSize.x < aX || imageSize.y < aY )
38 BOOST_TEST_INFO(
"Pixel (" << aX <<
", " << aY <<
"is not in image of size (" << imageSize.x
39 <<
", " << imageSize.y <<
")" );
43 const int r = aImage.GetRed( aX, aY );
44 const int g = aImage.GetGreen( aX, aY );
45 const int b = aImage.GetBlue( aX, aY );
47 const int a = aImage.HasAlpha() ? aImage.GetAlpha( aX, aY ) : 255;
51 BOOST_TEST_INFO(
"Colour doesn't match: got rgba(" << r <<
", " << g <<
", " << b <<
", "
52 << a <<
"), expected " << aColor );
62 if( aImgA.GetSize() != aImgB.GetSize() )
64 BOOST_TEST_INFO(
"Image sizes differ: " << aImgA.GetSize().GetWidth() <<
"x"
65 << aImgA.GetSize().GetHeight() <<
" vs "
66 << aImgB.GetSize().GetWidth() <<
"x"
67 << aImgB.GetSize().GetHeight() );
71 for(
int y = 0; y < aImgA.GetHeight(); ++y )
73 for(
int x = 0; x < aImgA.GetWidth(); ++x )
75 const int rA = aImgA.GetRed( x, y );
76 const int gA = aImgA.GetGreen( x, y );
77 const int bA = aImgA.GetBlue( x, y );
79 const int rB = aImgB.GetRed( x, y );
80 const int gB = aImgB.GetGreen( x, y );
81 const int bB = aImgB.GetBlue( x, y );
83 if( rA != rB || gA != gB || bA != bB )
85 BOOST_TEST_INFO(
"Pixel (" << x <<
", " << y <<
") differs: "
86 <<
"A(" << rA <<
", " << gA <<
", " << bA <<
") "
87 <<
"B(" << rB <<
", " << gB <<
", " << bB <<
")" );
101 const wxSize size = aImage.GetSize();
102 os <<
"wxImage[" << size.x <<
"x" << size.y <<
"]";
A color representation with 4 components: red, green, blue, alpha.
Test utilities for COLOUR4D objects.
bool IsColorNearHex(const KIGFX::COLOR4D &aCol, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Checks if a COLOR4D is close enough to a given RGB char value.
bool IsImagePixelOfColor(const wxImage &aImage, int aX, int aY, const KIGFX::COLOR4D &aColor)
Predicate to check an image pixel matches color and alpha.
bool ImagesHaveSamePixels(const wxImage &aImgA, const wxImage &aImgB)
Check if an image is identical to another image, pixel by pixel.
std::ostream & boost_test_print_type(std::ostream &os, wxImage const &aImage)