NAME
SDL2::pixels - Enumerated Pixel Format Definitions
SYNOPSIS
use SDL2 qw[:pixels];
DESCRIPTION
SDL2::pixels defines pixel format values and related functions.
Functions
SDL_GetPixelFormatName( ... )
Get the human readable name of a pixel format.
SDL_GetPixelFormatName(370546692);
Expected parameters include:
Returns the human readable name of the specified pixel format or SDL_PIXELFORMAT_UNKNOWN if the format isn't recognized.
SDL_PixelFormatEnumToMasks( ... )
Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
SDL_PixelFormatEnumToMasks(
SDL_PIXELFORMAT_ABGR8888,
\my $bpp,
\my $rmask, \my $bmask, \my $gmask, \my $amask
) || return SDL_SetError('Unknown format');
Expected parameters include:
format- one of the SDL_PixelFormatEnum valuesbpp- a bits per pixel value; usually 15, 16, or 32Rmask- a pointer filled in with the red mask for the formatGmask- a pointer filled in with the green mask for the formatBmask- a pointer filled in with the blue mask for the formatAmask- a pointer filled in with the alpha mask for the format
Returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't possible; call SDL_GetError( ) for more information.
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.
Expected parameters include:
bpp- a bits per pixel value; usually 15, 16, or 32Rmask- the red mask for the formatGmask- the green mask for the formatBmask- the blue mask for the formatAmask- the alpha mask for the format
Returns one of the SDL_PixelFormatEnum values.
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.
Expected parameters include:
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( ... ).
Expected parameters include:
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.
Expected parameters include:
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.
Expected parameters include:
format- the SDL2::PixelFormat structure that will use the palettepalette- the SDL2::Palette structure that will be used
Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.
SDL_SetPaletteColors( ... )
Set a range of colors in a palette.
Expected parameters include:
palette- the SDL_Palette structure to modifycolors- an array of SDL_Color structures to copy into the palettefirstcolor- the index of the first palette entry to modifyncolors- the number of entries to modify
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( ... ).
Expected parameters include:
palette- the SDL2::Palette structure to be freed
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).
Expected parameters include:
format- an SDL2::PixelFormat structure describing the pixel formatr- the red component of the pixel in the range 0-255g- the green component of the pixel in the range 0-255b- the blue component of the pixel in the range 0-255
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).
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).
Expected parameters include:
format- an SDL2::PixelFormat structure describing the format of the pixelr- the red component of the pixel in the range 0-255g- the green component of the pixel in the range 0-255b- the blue component of the pixel in the range 0-255a- the alpha component of the pixel in the range 0-255
Returns a pixel value.
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]).
Expected parameters include:
pixela pixel valueformatan SDL2::PixelFormat structure describing the format of the pixelr- a pointer filled in with the red componentg- a pointer filled in with the green componentb- a pointer filled in with the blue component
SDL_GetRGBA( ... )
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).
Expected parameters include:
pixel- a pixel valueformat- an SDL2::PixelFormat structure describing the format of the pixelr- a pointer filled in with the red componentg- a pointer filled in with the green componentb- a pointer filled in with the blue componenta- a pointer filled in with the alpha component
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
Expected parameters include:
gamma- a gamma value where0.0is black and1.0is identityramp- an array of 256 values filled in with the gamma ramp
Transparency definitions
These define alpha as the opacity of a surface.
SDL_ALPHA_OPAQUESDL_ALPHA_TRANSPARENT
SDL_PixelType
These may be imported with the tag :pixelType
SDL_PIXELTYPE_UNKNOWNSDL_PIXELTYPE_INDEX1SDL_PIXELTYPE_INDEX4SDL_PIXELTYPE_INDEX8SDL_PIXELTYPE_PACKED8SDL_PIXELTYPE_PACKED16SDL_PIXELTYPE_PACKED32SDL_PIXELTYPE_ARRAYU8SDL_PIXELTYPE_ARRAYU16SDL_PIXELTYPE_ARRAYU32SDL_PIXELTYPE_ARRAYF16SDL_PIXELTYPE_ARRAYF32
SDL_BitmapOrder
Bitmap pixel order, high bit -> low bit. These maybe imported with the :bitmapOrder tag.
SDL_BITMAPORDER_NONESDL_BITMAPORDER_4321SDL_BITMAPORDER_1234
SDL_PackedOrder
Packed component order, high bit -> low bit. These may be imported with the :packedOrder tag.
SDL_PACKEDORDER_NONESDL_PACKEDORDER_XRGBSDL_PACKEDORDER_RGBXSDL_PACKEDORDER_ARGBSDL_PACKEDORDER_RGBASDL_PACKEDORDER_XBGRSDL_PACKEDORDER_BGRXSDL_PACKEDORDER_ABGRSDL_PACKEDORDER_BGRA
SDL_ArrayOrder
Array component order, low byte -> high byte. These may be imported with the :arrayOrder tag.
SDL_ARRAYORDER_NONESDL_ARRAYORDER_RGBSDL_ARRAYORDER_RGBASDL_ARRAYORDER_ARGBSDL_ARRAYORDER_BGRSDL_ARRAYORDER_BGRASDL_ARRAYORDER_ABGR
SDL_PackedLayout
Packed component layout. These values may be imported with the :packedLayout tag.
SDL_PACKEDLAYOUT_NONESDL_PACKEDLAYOUT_332SDL_PACKEDLAYOUT_4444SDL_PACKEDLAYOUT_1555SDL_PACKEDLAYOUT_5551SDL_PACKEDLAYOUT_565SDL_PACKEDLAYOUT_8888SDL_PACKEDLAYOUT_2101010SDL_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( ... )
SDL_PixelFormatEnum
These values may be imported with the :pixelFormatEnum tag.
SDL_PIXELFORMAT_UNKNOWNSDL_PIXELFORMAT_INDEX1LSBSDL_PIXELFORMAT_INDEX1MSBSDL_PIXELFORMAT_INDEX4LSBSDL_PIXELFORMAT_INDEX4MSBSDL_PIXELFORMAT_INDEX8SDL_PIXELFORMAT_RGB332SDL_PIXELFORMAT_XRGB4444SDL_PIXELFORMAT_RGB444SDL_PIXELFORMAT_XBGR4444SDL_PIXELFORMAT_BGR444SDL_PIXELFORMAT_XRGB1555SDL_PIXELFORMAT_RGB555SDL_PIXELFORMAT_XBGR1555SDL_PIXELFORMAT_BGR555SDL_PIXELFORMAT_ARGB4444SDL_PIXELFORMAT_RGBA4444SDL_PIXELFORMAT_ABGR4444SDL_PIXELFORMAT_BGRA4444SDL_PIXELFORMAT_ARGB1555SDL_PIXELFORMAT_RGBA5551SDL_PIXELFORMAT_ABGR1555SDL_PIXELFORMAT_BGRA5551SDL_PIXELFORMAT_RGB565SDL_PIXELFORMAT_BGR565SDL_PIXELFORMAT_RGB24SDL_PIXELFORMAT_BGR24SDL_PIXELFORMAT_XRGB8888SDL_PIXELFORMAT_RGB888SDL_PIXELFORMAT_RGBX8888SDL_PIXELFORMAT_XBGR8888SDL_PIXELFORMAT_BGR888SDL_PIXELFORMAT_BGRX8888SDL_PIXELFORMAT_ARGB8888SDL_PIXELFORMAT_RGBA8888SDL_PIXELFORMAT_ABGR8888SDL_PIXELFORMAT_BGRA8888SDL_PIXELFORMAT_ARGB2101010SDL_PIXELFORMAT_RGBA32SDL_PIXELFORMAT_ARGB32SDL_PIXELFORMAT_BGRA32SDL_PIXELFORMAT_ABGR32SDL_PIXELFORMAT_YV12- Planar mode: Y + V + U (3 planes)SDL_PIXELFORMAT_IYUV- Planar mode: Y + U + V (3 planes)SDL_PIXELFORMAT_YUY2- Packed mode: Y0+U0+Y1+V0 (1 plane)SDL_PIXELFORMAT_UYVY- Packed mode: U0+Y0+V0+Y1 (1 plane)SDL_PIXELFORMAT_YVYU- Packed mode: Y0+V0+Y1+U0 (1 plane)SDL_PIXELFORMAT_NV12- Planar mode: Y + U/V interleaved (2 planes)SDL_PIXELFORMAT_NV21- Planar mode: Y + V/U interleaved (2 planes)SDL_PIXELFORMAT_EXTERNAL_OES- Android video texture format
LICENSE
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.
AUTHOR
Sanko Robinson <sanko@cpan.org>