sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Pixels

Description

SDL offers facilities for pixel management.

Largely these facilities deal with pixel format: what does this set of bits represent?

If you mostly want to think of a pixel as some combination of red, green, blue, and maybe alpha intensities, this is all pretty straightforward, and in many cases, is enough information to build a perfectly fine game.

However, the actual definition of a pixel is more complex than that:

Pixels are a representation of a color in a particular color space.

The first characteristic of a color space is the color type. SDL understands two different color types, RGB and YCbCr, or in SDL also referred to as YUV.

RGB colors consist of red, green, and blue channels of color that are added together to represent the colors we see on the screen.

https://en.wikipedia.org/wiki/RGB_color_model

YCbCr colors represent colors as a Y luma brightness component and red and blue chroma color offsets. This color representation takes advantage of the fact that the human eye is more sensitive to brightness than the color in an image. The Cb and Cr components are often compressed and have lower resolution than the luma component.

https://en.wikipedia.org/wiki/YCbCr

When the color information in YCbCr is compressed, the Y pixels are left at full resolution and each Cr and Cb pixel represents an average of the color information in a block of Y pixels. The chroma location determines where in that block of pixels the color information is coming from.

The color range defines how much of the pixel to use when converting a pixel into a color on the display. When the full color range is used, the entire numeric range of the pixel bits is significant. When narrow color range is used, for historical reasons, the pixel uses only a portion of the numeric range to represent colors.

The color primaries and white point are a definition of the colors in the color space relative to the standard XYZ color space.

https://en.wikipedia.org/wiki/CIE_1931_color_space

The transfer characteristic, or opto-electrical transfer function (OETF), is the way a color is converted from mathematically linear space into a non-linear output signals.

https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics

The matrix coefficients are used to convert between YCbCr and RGB colors. A fully opaque 8-bit alpha value.

See also
sDL_ALPHA_TRANSPARENT

FFI conventions

Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Pixels.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.

The C shims are functions this package defines in C over what the FFI cannot call directly (variadic functions, function-like macros), each named after what it wraps; the same flavor rules apply. Their raw imports live under SDL3.Sys.Bindgen.PixelsShims.

Full conventions: SDL3.Sys.

Since: 3.2.0

Synopsis

Documentation

Function aliases

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.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetPixelFormatName. The safe flavor is getPixelFormatNameSafe .
C declaration
SDL_GetPixelFormatName, defined at SDL3/SDL_pixels.h 1185:42

Since: 3.2.0

getPixelFormatNameSafe 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.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetPixelFormatName. The unsafe flavor is getPixelFormatName .
C declaration
SDL_GetPixelFormatName, defined at SDL3/SDL_pixels.h 1185:42

Since: 3.2.0

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 Bool 

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getPixelFormatForMasks

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetMasksForPixelFormat. The safe flavor is getMasksForPixelFormatSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetMasksForPixelFormat, defined at SDL3/SDL_pixels.h 1205:34

Since: 3.2.0

getMasksForPixelFormatSafe 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 Bool 

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

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getPixelFormatForMasks

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetMasksForPixelFormat. The unsafe flavor is getMasksForPixelFormat .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetMasksForPixelFormat, defined at SDL3/SDL_pixels.h 1205:34

Since: 3.2.0

getPixelFormatForMasks Source #

Arguments

:: Int32
bpp
a bits per pixel value; usually 15, 16, or 32.
-> Word32
Rmask
the red mask for the format.
-> Word32
Gmask
the green mask for the format.
-> Word32
Bmask
the blue mask for the format.
-> Word32
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
getMasksForPixelFormat

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetPixelFormatForMasks. The safe flavor is getPixelFormatForMasksSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetPixelFormatForMasks, defined at SDL3/SDL_pixels.h 1227:45

Since: 3.2.0

getPixelFormatForMasksSafe Source #

Arguments

:: Int32
bpp
a bits per pixel value; usually 15, 16, or 32.
-> Word32
Rmask
the red mask for the format.
-> Word32
Gmask
the green mask for the format.
-> Word32
Bmask
the blue mask for the format.
-> Word32
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
getMasksForPixelFormat

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetPixelFormatForMasks. The unsafe flavor is getPixelFormatForMasks .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetPixelFormatForMasks, defined at SDL3/SDL_pixels.h 1227:45

Since: 3.2.0

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 getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetPixelFormatDetails. The safe flavor is getPixelFormatDetailsSafe .
C declaration
SDL_GetPixelFormatDetails, defined at SDL3/SDL_pixels.h 1244:60

Since: 3.2.0

getPixelFormatDetailsSafe 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 getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetPixelFormatDetails. The unsafe flavor is getPixelFormatDetails .
C declaration
SDL_GetPixelFormatDetails, defined at SDL3/SDL_pixels.h 1244:60

Since: 3.2.0

createPalette Source #

Arguments

:: Int32
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 getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
destroyPalette, setPaletteColors, setSurfacePalette

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CreatePalette. The safe flavor is createPaletteSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CreatePalette, defined at SDL3/SDL_pixels.h 1264:43

Since: 3.2.0

createPaletteSafe Source #

Arguments

:: Int32
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 getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
destroyPalette, setPaletteColors, setSurfacePalette

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CreatePalette. The unsafe flavor is createPalette .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_CreatePalette, defined at SDL3/SDL_pixels.h 1264:43

Since: 3.2.0

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.
-> Int32
firstcolor
the index of the first palette entry to modify.
-> Int32
ncolors
the number of entries to modify.
-> IO Bool 

Set a range of colors in a palette.

Returns
true on success or false on failure; call 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.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetPaletteColors. The safe flavor is setPaletteColorsSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetPaletteColors, defined at SDL3/SDL_pixels.h 1281:34

Since: 3.2.0

setPaletteColorsSafe 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.
-> Int32
firstcolor
the index of the first palette entry to modify.
-> Int32
ncolors
the number of entries to modify.
-> IO Bool 

Set a range of colors in a palette.

Returns
true on success or false on failure; call 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.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetPaletteColors. The unsafe flavor is setPaletteColors .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetPaletteColors, defined at SDL3/SDL_pixels.h 1281:34

Since: 3.2.0

destroyPalette Source #

Arguments

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

Free a palette created with 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
createPalette

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_DestroyPalette. The safe flavor is destroyPaletteSafe .
C declaration
SDL_DestroyPalette, defined at SDL3/SDL_pixels.h 1295:34

Since: 3.2.0

destroyPaletteSafe Source #

Arguments

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

Free a palette created with 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
createPalette

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_DestroyPalette. The unsafe flavor is destroyPalette .
C declaration
SDL_DestroyPalette, defined at SDL3/SDL_pixels.h 1295:34

Since: 3.2.0

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.
-> Word8
r
the red component of the pixel in the range 0-255.
-> Word8
g
the green component of the pixel in the range 0-255.
-> Word8
b
the blue component of the pixel in the range 0-255.
-> IO Word32 

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
getPixelFormatDetails, getRGB, mapRGBA, mapSurfaceRGB

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_MapRGB. The safe flavor is mapRGBSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_MapRGB, defined at SDL3/SDL_pixels.h 1333:36

Since: 3.2.0

mapRGBSafe 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.
-> Word8
r
the red component of the pixel in the range 0-255.
-> Word8
g
the green component of the pixel in the range 0-255.
-> Word8
b
the blue component of the pixel in the range 0-255.
-> IO Word32 

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
getPixelFormatDetails, getRGB, mapRGBA, mapSurfaceRGB

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_MapRGB. The unsafe flavor is mapRGB .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_MapRGB, defined at SDL3/SDL_pixels.h 1333:36

Since: 3.2.0

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.
-> Word8
r
the red component of the pixel in the range 0-255.
-> Word8
g
the green component of the pixel in the range 0-255.
-> Word8
b
the blue component of the pixel in the range 0-255.
-> Word8
a
the alpha component of the pixel in the range 0-255.
-> IO Word32 

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
getPixelFormatDetails, getRGBA, mapRGB, mapSurfaceRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_MapRGBA. The safe flavor is mapRGBASafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_MapRGBA, defined at SDL3/SDL_pixels.h 1372:36

Since: 3.2.0

mapRGBASafe 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.
-> Word8
r
the red component of the pixel in the range 0-255.
-> Word8
g
the green component of the pixel in the range 0-255.
-> Word8
b
the blue component of the pixel in the range 0-255.
-> Word8
a
the alpha component of the pixel in the range 0-255.
-> IO Word32 

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
getPixelFormatDetails, getRGBA, mapRGB, mapSurfaceRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_MapRGBA. The unsafe flavor is mapRGBA .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_MapRGBA, defined at SDL3/SDL_pixels.h 1372:36

Since: 3.2.0

getRGB Source #

Arguments

:: Word32
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
getPixelFormatDetails, getRGBA, mapRGB, mapRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetRGB. The safe flavor is getRGBSafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetRGB, defined at SDL3/SDL_pixels.h 1400:34

Since: 3.2.0

getRGBSafe Source #

Arguments

:: Word32
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
getPixelFormatDetails, getRGBA, mapRGB, mapRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetRGB. The unsafe flavor is getRGB .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetRGB, defined at SDL3/SDL_pixels.h 1400:34

Since: 3.2.0

getRGBA Source #

Arguments

:: Word32
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
getPixelFormatDetails, getRGB, mapRGB, mapRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetRGBA. The safe flavor is getRGBASafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetRGBA, defined at SDL3/SDL_pixels.h 1432:34

Since: 3.2.0

getRGBASafe Source #

Arguments

:: Word32
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
getPixelFormatDetails, getRGB, mapRGB, mapRGBA

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetRGBA. The unsafe flavor is getRGBA .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_GetRGBA, defined at SDL3/SDL_pixels.h 1432:34

Since: 3.2.0

C shims

definePixelFourCC Source #

Arguments

:: Word8
a
the first character of the FourCC code.
-> Word8
b
the second character of the FourCC code.
-> Word8
c
the third character of the FourCC code.
-> Word8
d
the fourth character of the FourCC code.
-> IO SDL_PixelFormat 

Define a custom FourCC pixel format.

The SDL_DEFINE_PIXELFOURCC macro as a function. SDL_PIXELFORMAT_YV12, for example, is the code of the characters Y, V, 1, 2.

Returns
a format value in the style of SDL_PixelFormat.
Thread safety
It is safe to call this function from any thread.
See also
fourCC

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_DEFINE_PIXELFOURCC. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_DEFINE_PIXELFOURCC, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 42:35

Since: 3.2.0

bitsPerPixel Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Int32 

Determine an SDL_PixelFormat's bits per pixel.

The SDL_BITSPERPIXEL macro as a function. FourCC formats report zero here, as it rarely makes sense to measure them per-pixel.

Returns
the bits-per-pixel of format.
Thread safety
It is safe to call this function from any thread.
See also
bytesPerPixel

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_BITSPERPIXEL. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_BITSPERPIXEL, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 62:23

Since: 3.2.0

bytesPerPixel Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Int32 

Determine an SDL_PixelFormat's bytes per pixel.

The SDL_BYTESPERPIXEL macro as a function. FourCC formats do their best here, but many of them don't have a meaningful measurement of bytes per pixel.

Returns
the bytes-per-pixel of format.
Thread safety
It is safe to call this function from any thread.
See also
bitsPerPixel

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_BYTESPERPIXEL. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_BYTESPERPIXEL, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 83:23

Since: 3.2.0

isPixelFormatIndexed Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is an indexed format.

The SDL_ISPIXELFORMAT_INDEXED macro as a function.

Returns
true if the format is indexed, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_INDEXED. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_INDEXED, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 100:24

Since: 3.2.0

isPixelFormatPacked Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is a packed format.

The SDL_ISPIXELFORMAT_PACKED macro as a function.

Returns
true if the format is packed, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_PACKED. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_PACKED, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 117:24

Since: 3.2.0

isPixelFormatArray Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is an array format.

The SDL_ISPIXELFORMAT_ARRAY macro as a function.

Returns
true if the format is an array, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_ARRAY. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_ARRAY, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 134:24

Since: 3.2.0

isPixelFormat10Bit Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is a 10-bit format.

The SDL_ISPIXELFORMAT_10BIT macro as a function.

Returns
true if the format is 10-bit, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_10BIT. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_10BIT, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 151:24

Since: 3.2.0

isPixelFormatFloat Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is a floating point format.

The SDL_ISPIXELFORMAT_FLOAT macro as a function.

Returns
true if the format is a floating point, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_FLOAT. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_FLOAT, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 168:24

Since: 3.2.0

isPixelFormatAlpha Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat has an alpha channel.

The SDL_ISPIXELFORMAT_ALPHA macro as a function.

Returns
true if the format has alpha, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_ALPHA. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_ALPHA, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 185:24

Since: 3.2.0

isPixelFormatFourCC Source #

Arguments

:: SDL_PixelFormat
format
an SDL_PixelFormat to check.
-> IO Bool 

Determine if an SDL_PixelFormat is a "FourCC" format.

The SDL_ISPIXELFORMAT_FOURCC macro as a function. This covers custom and other unusual formats.

Returns
true if the format is a FourCC format, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISPIXELFORMAT_FOURCC. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISPIXELFORMAT_FOURCC, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 202:24

Since: 3.2.0

defineColorspace Source #

Arguments

:: SDL_ColorType
type
the type of the new format.
-> SDL_ColorRange
range
the range of the new format.
-> SDL_ColorPrimaries
primaries
the primaries of the new format.
-> SDL_TransferCharacteristics
transfer
the transfer characteristics of the new format.
-> SDL_MatrixCoefficients
matrix
the matrix coefficients of the new format.
-> SDL_ChromaLocation
chroma
the chroma sample location of the new format.
-> IO SDL_Colorspace 

Define a custom colorspace.

The SDL_DEFINE_COLORSPACE macro as a function.

Returns
a format value in the style of SDL_Colorspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_DEFINE_COLORSPACE. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_DEFINE_COLORSPACE, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 224:34

Since: 3.2.0

colorspaceType Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_ColorType 

Retrieve the type of an SDL_Colorspace.

The SDL_COLORSPACETYPE macro as a function.

Returns
the SDL_ColorType of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACETYPE. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACETYPE, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 241:33

Since: 3.2.0

colorspaceRange Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_ColorRange 

Retrieve the range of an SDL_Colorspace.

The SDL_COLORSPACERANGE macro as a function.

Returns
the SDL_ColorRange of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACERANGE. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACERANGE, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 258:34

Since: 3.2.0

colorspaceChroma Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_ChromaLocation 

Retrieve the chroma sample location of an SDL_Colorspace.

The SDL_COLORSPACECHROMA macro as a function.

Returns
the SDL_ChromaLocation of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACECHROMA. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACECHROMA, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 275:38

Since: 3.2.0

colorspacePrimaries Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_ColorPrimaries 

Retrieve the primaries of an SDL_Colorspace.

The SDL_COLORSPACEPRIMARIES macro as a function.

Returns
the SDL_ColorPrimaries of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACEPRIMARIES. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACEPRIMARIES, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 292:38

Since: 3.2.0

colorspaceTransfer Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_TransferCharacteristics 

Retrieve the transfer characteristics of an SDL_Colorspace.

The SDL_COLORSPACETRANSFER macro as a function.

Returns
the SDL_TransferCharacteristics of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACETRANSFER. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACETRANSFER, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 309:47

Since: 3.2.0

colorspaceMatrix Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO SDL_MatrixCoefficients 

Retrieve the matrix coefficients of an SDL_Colorspace.

The SDL_COLORSPACEMATRIX macro as a function.

Returns
the SDL_MatrixCoefficients of cspace.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_COLORSPACEMATRIX. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
C declaration
lithon_SDL_COLORSPACEMATRIX, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 326:42

Since: 3.2.0

isColorspaceMatrixBT601 Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO Bool 

Determine if an SDL_Colorspace uses BT601 (or BT470BG) matrix coefficients.

The SDL_ISCOLORSPACE_MATRIX_BT601 macro as a function.

Returns
true if BT601 or BT470BG, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISCOLORSPACE_MATRIX_BT601. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISCOLORSPACE_MATRIX_BT601, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 343:24

Since: 3.2.0

isColorspaceMatrixBT709 Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO Bool 

Determine if an SDL_Colorspace uses BT709 matrix coefficients.

The SDL_ISCOLORSPACE_MATRIX_BT709 macro as a function.

Returns
true if BT709, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISCOLORSPACE_MATRIX_BT709. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISCOLORSPACE_MATRIX_BT709, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 360:24

Since: 3.2.0

isColorspaceMatrixBT2020NCL Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO Bool 

Determine if an SDL_Colorspace uses BT2020_NCL matrix coefficients.

The SDL_ISCOLORSPACE_MATRIX_BT2020_NCL macro as a function.

Returns
true if BT2020_NCL, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISCOLORSPACE_MATRIX_BT2020_NCL. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISCOLORSPACE_MATRIX_BT2020_NCL, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 377:24

Since: 3.2.0

isColorspaceLimitedRange Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO Bool 

Determine if an SDL_Colorspace has a limited range.

The SDL_ISCOLORSPACE_LIMITED_RANGE macro as a function.

Returns
true if limited range, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISCOLORSPACE_LIMITED_RANGE. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISCOLORSPACE_LIMITED_RANGE, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 394:24

Since: 3.2.0

isColorspaceFullRange Source #

Arguments

:: SDL_Colorspace
cspace
an SDL_Colorspace to check.
-> IO Bool 

Determine if an SDL_Colorspace has a full range.

The SDL_ISCOLORSPACE_FULL_RANGE macro as a function.

Returns
true if full range, false otherwise.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_ISCOLORSPACE_FULL_RANGE. The safe import is not exported : pure bit manipulation on immediate values; cannot block, lock, or call back.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
lithon_SDL_ISCOLORSPACE_FULL_RANGE, defined at sdl3-bindgen-sys/SDL_pixels_shims.h 411:24

Since: 3.2.0