SDL 3.0
SDL_test_compare.h File Reference
#include <SDL3/SDL.h>
#include <SDL3/SDL_begin_code.h>
#include <SDL3/SDL_close_code.h>
+ Include dependency graph for SDL_test_compare.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int SDLTest_ReadSurfacePixel (SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
 
int SDLTest_CompareSurfaces (SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error)
 

Detailed Description

Comparison function of SDL test framework.

This code is a part of the SDL test library, not the main SDL library.

Definition in file SDL_test_compare.h.

Function Documentation

◆ SDLTest_CompareSurfaces()

int SDLTest_CompareSurfaces ( SDL_Surface surface,
SDL_Surface referenceSurface,
int  allowable_error 
)

Compares a surface and with reference image data for equality

Parameters
surfaceSurface used in comparison
referenceSurfaceTest Surface used in comparison
allowable_errorAllowable difference (=sum of squared difference for each RGB component) in blending accuracy.
Returns
0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.

◆ SDLTest_ReadSurfacePixel()

int SDLTest_ReadSurfacePixel ( SDL_Surface surface,
int  x,
int  y,
Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a 
)

Retrieves a single pixel from a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Like SDL_GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters
surfaceThe surface
xHorizontal coordinate, 0 <= x < width
yVertical coordinate, 0 <= y < height
rPointer to location to store red channel, 0-255
gPointer to location to store green channel, 0-255
bPointer to location to store blue channel, 0-255
aPointer to location to store alpha channel, 0-255
Returns
0 if the surface is valid and the coordinates are in-bounds