SDL2::pixels - Enumerated Pixel Format Definitions
use SDL2 qw[:pixels];
SDL2::pixels defines pixel format values and related functions.
SDL_GetPixelFormatName( ... )
Get the human readable name of a pixel format.
SDL_GetPixelFormatName(370546692);
Expected parameters include:
format
Returns the human readable name of the specified pixel format or SDL_PIXELFORMAT_UNKNOWN if the format isn't recognized.
SDL_PIXELFORMAT_UNKNOWN
SDL_PixelFormatEnumToMasks( ... )
Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
bpp
SDL_PixelFormatEnumToMasks( SDL_PIXELFORMAT_ABGR8888, \my $bpp, \my $rmask, \my $bmask, \my $gmask, \my $amask ) || return SDL_SetError('Unknown format');
Rmask
Gmask
Bmask
Amask
Returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't possible; call SDL_GetError( ) for more information.
SDL_TRUE
SDL_FALSE
SDL_GetError( )
SDL_MasksToPixelFormatEnum( ... )
Convert a bpp value and RGBA masks to an enumerated pixel format.
# ARGB8888 my $amask = 0xff000000; my $rmask = 0x00ff0000; my $gmask = 0x0000ff00; my $bmask = 0x000000ff; SDL_MasksToPixelFormatEnum( 32, $rmask, $gmask, $bmask, $amask );
This will return SDL_PIXELFORMAT_UNKNOWN if the conversion wasn't possible.
Returns one of the SDL_PixelFormatEnum values.
SDL_PixelFormatEnum
SDL_AllocFormat( ... )
Create an SDL2::PixelFormat structure corresponding to a pixel format.
# ARGB8888 my $amask = 0xff000000; my $rmask = 0x00ff0000; my $gmask = 0x0000ff00; my $bmask = 0x000000ff; my $format = SDL_AllocFormat( SDL_MasksToPixelFormatEnum( 32, $rmask, $gmask, $bmask, $amask ) );
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.
Blit combination not supported
pixel_format
Returns the new SDL2::PixelFormat structure or undef on failure; call SDL_GetError( ) for more information.
SDL_FreeFormat( ... )
Free an SDL_PixelFormat structure allocated by SDL_AllocFormat( ... ).
SDL2::PixelFormat
SDL_AllocPalette( ... )
Create a palette structure with the specified number of color entries.
my $palette = SDL_AllocPalette(256);
The palette entries are initialized to white.
ncolors
Returns a new SDL2::Palette structure on success or undef on failure (e.g. if there wasn't enough memory); call SDL_GetError( ) for more information.
SDL_SetPixelFormatPalette( ... )
Set the palette for a pixel format structure.
palette
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
0
SDL_SetPaletteColors( ... )
Set a range of colors in a palette.
colors
firstcolor
Returns 0 on success or a negative error code if not all of the colors could be set; call SDL_GetError( ) for more information.
SDL_FreePalette( ... )
Free a palette created with SDL_AllocPalette( ... ).
SDL_MapRGB( ... )
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).
r
g
b
Returns a pixel value.
SDL_MapRGBA( ... )
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).
a
SDL_GetRGB( ... )
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]).
[0xff, 0xff, 0xff]
[0xf8, 0xfc, 0xf8]
pixel
SDL_GetRGBA( ... )
Get RGBA values from a pixel in the specified format.
If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque).
SDL_CalculateGammaRamp( ... )
Calculate a 256 entry gamma ramp for a gamma value.
my @ramp = (0) x 256; # preallocate to avoid spurious warnings SDL_CalculateGammaRamp( .925, \@ramp ); # \@ramp will be filled
gamma
0.0
1.0
ramp
These define alpha as the opacity of a surface.
SDL_ALPHA_OPAQUE
SDL_ALPHA_TRANSPARENT
These may be imported with the tag :pixelType
:pixelType
SDL_PIXELTYPE_UNKNOWN
SDL_PIXELTYPE_INDEX1
SDL_PIXELTYPE_INDEX4
SDL_PIXELTYPE_INDEX8
SDL_PIXELTYPE_PACKED8
SDL_PIXELTYPE_PACKED16
SDL_PIXELTYPE_PACKED32
SDL_PIXELTYPE_ARRAYU8
SDL_PIXELTYPE_ARRAYU16
SDL_PIXELTYPE_ARRAYU32
SDL_PIXELTYPE_ARRAYF16
SDL_PIXELTYPE_ARRAYF32
Bitmap pixel order, high bit -> low bit. These maybe imported with the :bitmapOrder tag.
:bitmapOrder
SDL_BITMAPORDER_NONE
SDL_BITMAPORDER_4321
SDL_BITMAPORDER_1234
Packed component order, high bit -> low bit. These may be imported with the :packedOrder tag.
:packedOrder
SDL_PACKEDORDER_NONE
SDL_PACKEDORDER_XRGB
SDL_PACKEDORDER_RGBX
SDL_PACKEDORDER_ARGB
SDL_PACKEDORDER_RGBA
SDL_PACKEDORDER_XBGR
SDL_PACKEDORDER_BGRX
SDL_PACKEDORDER_ABGR
SDL_PACKEDORDER_BGRA
Array component order, low byte -> high byte. These may be imported with the :arrayOrder tag.
:arrayOrder
SDL_ARRAYORDER_NONE
SDL_ARRAYORDER_RGB
SDL_ARRAYORDER_RGBA
SDL_ARRAYORDER_ARGB
SDL_ARRAYORDER_BGR
SDL_ARRAYORDER_BGRA
SDL_ARRAYORDER_ABGR
Packed component layout. These values may be imported with the :packedLayout tag.
:packedLayout
SDL_PACKEDLAYOUT_NONE
SDL_PACKEDLAYOUT_332
SDL_PACKEDLAYOUT_4444
SDL_PACKEDLAYOUT_1555
SDL_PACKEDLAYOUT_5551
SDL_PACKEDLAYOUT_565
SDL_PACKEDLAYOUT_8888
SDL_PACKEDLAYOUT_2101010
SDL_PACKEDLAYOUT_1010102
:pixels
These utility functions may be imported with the :pixels tag.
SDL_DEFINE_PIXELFOURCC( ... )
SDL_DEFINE_PIXELFORMAT( ... )
SDL_PIXELFLAG( ... )
SDL_PIXELTYPE( ... )
SDL_PIXELORDER( ... )
SDL_PIXELLAYOUT( ... )
SDL_BITSPERPIXEL( ... )
SDL_BYTESPERPIXEL( ... )
SDL_ISPIXELFORMAT_INDEXED( ... )
SDL_ISPIXELFORMAT_PACKED( ... )
SDL_ISPIXELFORMAT_ARRAY( ... )
SDL_ISPIXELFORMAT_ALPHA( ... )
SDL_ISPIXELFORMAT_FOURCC( ... )
These values may be imported with the :pixelFormatEnum tag.
:pixelFormatEnum
SDL_PIXELFORMAT_INDEX1LSB
SDL_PIXELFORMAT_INDEX1MSB
SDL_PIXELFORMAT_INDEX4LSB
SDL_PIXELFORMAT_INDEX4MSB
SDL_PIXELFORMAT_INDEX8
SDL_PIXELFORMAT_RGB332
SDL_PIXELFORMAT_XRGB4444
SDL_PIXELFORMAT_RGB444
SDL_PIXELFORMAT_XBGR4444
SDL_PIXELFORMAT_BGR444
SDL_PIXELFORMAT_XRGB1555
SDL_PIXELFORMAT_RGB555
SDL_PIXELFORMAT_XBGR1555
SDL_PIXELFORMAT_BGR555
SDL_PIXELFORMAT_ARGB4444
SDL_PIXELFORMAT_RGBA4444
SDL_PIXELFORMAT_ABGR4444
SDL_PIXELFORMAT_BGRA4444
SDL_PIXELFORMAT_ARGB1555
SDL_PIXELFORMAT_RGBA5551
SDL_PIXELFORMAT_ABGR1555
SDL_PIXELFORMAT_BGRA5551
SDL_PIXELFORMAT_RGB565
SDL_PIXELFORMAT_BGR565
SDL_PIXELFORMAT_RGB24
SDL_PIXELFORMAT_BGR24
SDL_PIXELFORMAT_XRGB8888
SDL_PIXELFORMAT_RGB888
SDL_PIXELFORMAT_RGBX8888
SDL_PIXELFORMAT_XBGR8888
SDL_PIXELFORMAT_BGR888
SDL_PIXELFORMAT_BGRX8888
SDL_PIXELFORMAT_ARGB8888
SDL_PIXELFORMAT_RGBA8888
SDL_PIXELFORMAT_ABGR8888
SDL_PIXELFORMAT_BGRA8888
SDL_PIXELFORMAT_ARGB2101010
SDL_PIXELFORMAT_RGBA32
SDL_PIXELFORMAT_ARGB32
SDL_PIXELFORMAT_BGRA32
SDL_PIXELFORMAT_ABGR32
SDL_PIXELFORMAT_YV12
SDL_PIXELFORMAT_IYUV
SDL_PIXELFORMAT_YUY2
SDL_PIXELFORMAT_UYVY
SDL_PIXELFORMAT_YVYU
SDL_PIXELFORMAT_NV12
SDL_PIXELFORMAT_NV21
SDL_PIXELFORMAT_EXTERNAL_OES
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
Sanko Robinson <sanko@cpan.org>
To install SDL2::FFI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL2::FFI
CPAN shell
perl -MCPAN -e shell install SDL2::FFI
For more information on module installation, please visit the detailed CPAN module installation guide.