43 int bpp, bpp_reference;
46 int sampleErrorX = 0, sampleErrorY = 0, sampleDist = 0;
49 char imageFilename[128];
50 char referenceFilename[128];
53 if (surface ==
NULL || referenceSurface ==
NULL) {
58 if ((surface->
w != referenceSurface->
w) || (surface->
h != referenceSurface->
h)) {
63 if (allowable_error<0) {
74 for (j=0; j<surface->
h; j++) {
75 for (i=0; i<surface->
w; i++) {
77 p_reference = (
Uint8 *)referenceSurface->
pixels + j * referenceSurface->
pitch + i * bpp_reference;
83 dist += (R-Rd)*(R-Rd);
84 dist += (G-Gd)*(G-Gd);
85 dist += (B-Bd)*(B-Bd);
88 if (dist > allowable_error) {
105 SDLTest_LogError(
"Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret);
106 SDLTest_LogError(
"First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
111 SDLTest_LogError(
"Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);