sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Pixels.Safe

Synopsis

Documentation

sDL_GetPixelFormatName Source #

Arguments

:: SDL_PixelFormat
format
the pixel format to query.
-> IO (PtrConst CChar) 

Get the human readable name of a pixel format.

Returns
the human readable name of the specified pixel format or "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_GetPixelFormatName, defined at SDL3/SDL_pixels.h 1185:42

Since: 3.2.0

sDL_GetMasksForPixelFormat Source #

Arguments

:: SDL_PixelFormat
format
one of the SDL_PixelFormat values.
-> Ptr CInt
bpp
a bits per pixel value; usually 15, 16, or 32.
-> Ptr Uint32
Rmask
a pointer filled in with the red mask for the format.
-> Ptr Uint32
Gmask
a pointer filled in with the green mask for the format.
-> Ptr Uint32
Bmask
a pointer filled in with the blue mask for the format.
-> Ptr Uint32
Amask
a pointer filled in with the alpha mask for the format.
-> IO CBool 

Convert one of the enumerated pixel formats to a bpp value and RGBA masks.

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetPixelFormatForMasks
C declaration
SDL_GetMasksForPixelFormat, defined at SDL3/SDL_pixels.h 1205:34

Since: 3.2.0

sDL_GetPixelFormatForMasks Source #

Arguments

:: CInt
bpp
a bits per pixel value; usually 15, 16, or 32.
-> Uint32
Rmask
the red mask for the format.
-> Uint32
Gmask
the green mask for the format.
-> Uint32
Bmask
the blue mask for the format.
-> Uint32
Amask
the alpha mask for the format.
-> IO SDL_PixelFormat 

Convert a bpp value and RGBA masks to an enumerated pixel format.

This will return SDL_PIXELFORMAT_UNKNOWN if the conversion wasn't possible.

Returns
the SDL_PixelFormat value corresponding to the format masks, or SDL_PIXELFORMAT_UNKNOWN if there isn't a match.
Thread safety
It is safe to call this function from any thread.
See also
sDL_GetMasksForPixelFormat
C declaration
SDL_GetPixelFormatForMasks, defined at SDL3/SDL_pixels.h 1227:45

Since: 3.2.0

sDL_GetPixelFormatDetails Source #

Arguments

:: SDL_PixelFormat
format
one of the SDL_PixelFormat values.
-> IO (PtrConst SDL_PixelFormatDetails) 

Create an SDL_PixelFormatDetails structure corresponding to a pixel format.

Returned structure may come from a shared global cache (i.e. not newly allocated), and hence should not be modified, especially the palette. Weird errors such as Blit combination not supported may occur.

Returns
a pointer to a SDL_PixelFormatDetails structure or NULL on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
C declaration
SDL_GetPixelFormatDetails, defined at SDL3/SDL_pixels.h 1244:60

Since: 3.2.0

sDL_CreatePalette Source #

Arguments

:: CInt
ncolors
represents the number of color entries in the color palette.
-> IO (Ptr SDL_Palette) 

Create a palette structure with the specified number of color entries.

The palette entries are initialized to white.

Returns
a new SDL_Palette structure on success or NULL on failure (e.g. if there wasn't enough memory); call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_DestroyPalette, sDL_SetPaletteColors, SDL_SetSurfacePalette
C declaration
SDL_CreatePalette, defined at SDL3/SDL_pixels.h 1264:43

Since: 3.2.0

sDL_SetPaletteColors Source #

Arguments

:: Ptr SDL_Palette
palette
the SDL_Palette structure to modify.
-> PtrConst SDL_Color
colors
an array of SDL_Color structures to copy into the palette.
-> CInt
firstcolor
the index of the first palette entry to modify.
-> CInt
ncolors
the number of entries to modify.
-> IO CBool 

Set a range of colors in a palette.

Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
C declaration
SDL_SetPaletteColors, defined at SDL3/SDL_pixels.h 1281:34

Since: 3.2.0

sDL_DestroyPalette Source #

Arguments

:: Ptr SDL_Palette
palette
the SDL_Palette structure to be freed.
-> IO () 

Free a palette created with SDL_CreatePalette().

Thread safety
It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
See also
sDL_CreatePalette
C declaration
SDL_DestroyPalette, defined at SDL3/SDL_pixels.h 1295:34

Since: 3.2.0

sDL_MapRGB Source #

Arguments

:: PtrConst SDL_PixelFormatDetails
format
a pointer to SDL_PixelFormatDetails describing the pixel format.
-> PtrConst SDL_Palette
palette
an optional palette for indexed formats, may be NULL.
-> Uint8
r
the red component of the pixel in the range 0-255.
-> Uint8
g
the green component of the pixel in the range 0-255.
-> Uint8
b
the blue component of the pixel in the range 0-255.
-> IO Uint32 

Map an RGB triple to an opaque pixel value for a given pixel format.

This function maps the RGB color value to the specified pixel format and returns the pixel value best approximating the given RGB color value for the given pixel format.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Returns
a pixel value.
Thread safety
It is safe to call this function from any thread, as long as the palette is not modified.
See also
sDL_GetPixelFormatDetails, sDL_GetRGB, sDL_MapRGBA, SDL_MapSurfaceRGB
C declaration
SDL_MapRGB, defined at SDL3/SDL_pixels.h 1333:36

Since: 3.2.0

sDL_MapRGBA Source #

Arguments

:: PtrConst SDL_PixelFormatDetails
format
a pointer to SDL_PixelFormatDetails describing the pixel format.
-> PtrConst SDL_Palette
palette
an optional palette for indexed formats, may be NULL.
-> Uint8
r
the red component of the pixel in the range 0-255.
-> Uint8
g
the green component of the pixel in the range 0-255.
-> Uint8
b
the blue component of the pixel in the range 0-255.
-> Uint8
a
the alpha component of the pixel in the range 0-255.
-> IO Uint32 

Map an RGBA quadruple to a pixel value for a given pixel format.

This function maps the RGBA color value to the specified pixel format and returns the pixel value best approximating the given RGBA color value for the given pixel format.

If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Returns
a pixel value.
Thread safety
It is safe to call this function from any thread, as long as the palette is not modified.
See also
sDL_GetPixelFormatDetails, sDL_GetRGBA, sDL_MapRGB, SDL_MapSurfaceRGBA
C declaration
SDL_MapRGBA, defined at SDL3/SDL_pixels.h 1372:36

Since: 3.2.0

sDL_GetRGB Source #

Arguments

:: Uint32
pixelvalue
a pixel value.
-> PtrConst SDL_PixelFormatDetails
format
a pointer to SDL_PixelFormatDetails describing the pixel format.
-> PtrConst SDL_Palette
palette
an optional palette for indexed formats, may be NULL.
-> Ptr Uint8
r
a pointer filled in with the red component, may be NULL.
-> Ptr Uint8
g
a pointer filled in with the green component, may be NULL.
-> Ptr Uint8
b
a pointer filled in with the blue component, may be NULL.
-> IO () 

Get RGB values from a pixel in the specified format.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

Thread safety
It is safe to call this function from any thread, as long as the palette is not modified.
See also
sDL_GetPixelFormatDetails, sDL_GetRGBA, sDL_MapRGB, sDL_MapRGBA
C declaration
SDL_GetRGB, defined at SDL3/SDL_pixels.h 1400:34

Since: 3.2.0

sDL_GetRGBA Source #

Arguments

:: Uint32
pixelvalue
a pixel value.
-> PtrConst SDL_PixelFormatDetails
format
a pointer to SDL_PixelFormatDetails describing the pixel format.
-> PtrConst SDL_Palette
palette
an optional palette for indexed formats, may be NULL.
-> Ptr Uint8
r
a pointer filled in with the red component, may be NULL.
-> Ptr Uint8
g
a pointer filled in with the green component, may be NULL.
-> Ptr Uint8
b
a pointer filled in with the blue component, may be NULL.
-> Ptr Uint8
a
a pointer filled in with the alpha component, may be NULL.
-> IO () 

Get RGBA values from a pixel in the specified format.

This function uses the entire 8-bit [0..255] range when converting color components from pixel formats with less than 8-bits per RGB component (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).

If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque).

Thread safety
It is safe to call this function from any thread, as long as the palette is not modified.
See also
sDL_GetPixelFormatDetails, sDL_GetRGB, sDL_MapRGB, sDL_MapRGBA
C declaration
SDL_GetRGBA, defined at SDL3/SDL_pixels.h 1432:34

Since: 3.2.0