43 int bpp, bpp_reference;
48 char imageFilename[128];
49 char referenceFilename[128];
52 if (surface ==
NULL || referenceSurface ==
NULL) {
57 if ((surface->
w != referenceSurface->
w) || (surface->
h != referenceSurface->
h)) {
62 if (allowable_error<0) {
73 for (j=0; j<surface->
h; j++) {
74 for (i=0; i<surface->
w; i++) {
76 p_reference = (
Uint8 *)referenceSurface->
pixels + j * referenceSurface->
pitch + i * bpp_reference;
82 dist += (R-Rd)*(R-Rd);
83 dist += (G-Gd)*(G-Gd);
84 dist += (B-Bd)*(B-Bd);
87 if (dist > allowable_error) {
103 SDLTest_LogError(
"Surfaces from failed comparison saved as '%s' and '%s'", imageFilename, referenceFilename);
int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error)
Compares a surface and with reference image data for equality.
DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt,...)
A collection of pixels used in software blitting.
#define SDL_SaveBMP(surface, file)
static int _CompareSurfaceCount
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the RGBA components from a pixel of the specified format.
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
void SDLTest_LogError(const char *fmt,...)
Prints given message with a timestamp in the TEST category and the ERROR priority.