Made SDL_ReadSurfacePixel a public function

Fixes https://github.com/libsdl-org/SDL/issues/8320
This commit is contained in:
Sam Lantinga 2024-01-18 04:36:37 -08:00
parent f7ba340999
commit f8dfee01bb
9 changed files with 93 additions and 118 deletions

View file

@ -932,6 +932,31 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src,
const SDL_Rect *dstrect,
SDL_ScaleMode scaleMode);
/**
* 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.
*
* \param surface the surface to read
* \param x the horizontal coordinate, 0 <= x < width
* \param y the vertical coordinate, 0 <= y < height
* \param r a pointer filled in with the red channel, 0-255, or NULL to ignore this channel
* \param g a pointer filled in with the green channel, 0-255, or NULL to ignore this channel
* \param b a pointer filled in with the blue channel, 0-255, or NULL to ignore this channel
* \param a a pointer filled in with the alpha channel, 0-255, or NULL to ignore this channel
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/**
* Set the YUV conversion mode
*

View file

@ -44,27 +44,6 @@
extern "C" {
#endif
/**
* 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.
*
* \param surface The surface
* \param x Horizontal coordinate, 0 <= x < width
* \param y Vertical coordinate, 0 <= y < height
* \param r Pointer to location to store red channel, 0-255
* \param g Pointer to location to store green channel, 0-255
* \param b Pointer to location to store blue channel, 0-255
* \param a Pointer to location to store alpha channel, 0-255
* \returns 0 if the surface is valid and the coordinates are in-bounds
*/
int SDLTest_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/**
* Compares a surface and with reference image data for equality
*