2015-06-21 09:33:46 -06:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2022-01-03 10:40:00 -07:00
|
|
|
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file SDL_pixels.h
|
|
|
|
*
|
|
|
|
* Header for the enumerated pixel format definitions.
|
|
|
|
*/
|
|
|
|
|
2016-11-20 22:34:54 -07:00
|
|
|
#ifndef SDL_pixels_h_
|
|
|
|
#define SDL_pixels_h_
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2022-11-26 21:43:38 -07:00
|
|
|
#include <SDL3/SDL_stdinc.h>
|
|
|
|
#include <SDL3/SDL_endian.h>
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2022-11-26 21:43:38 -07:00
|
|
|
#include <SDL3/begin_code.h>
|
2015-06-21 09:33:46 -06:00
|
|
|
/* Set up for C function definitions, even when using C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \name Transparency definitions
|
|
|
|
*
|
|
|
|
* These define alpha as the opacity of a surface.
|
|
|
|
*/
|
|
|
|
/* @{ */
|
|
|
|
#define SDL_ALPHA_OPAQUE 255
|
|
|
|
#define SDL_ALPHA_TRANSPARENT 0
|
|
|
|
/* @} */
|
|
|
|
|
|
|
|
/** Pixel type. */
|
2019-10-10 09:40:00 -06:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
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
|
2019-10-10 22:18:24 -06:00
|
|
|
} SDL_PixelType;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/** Bitmap pixel order, high bit -> low bit. */
|
2019-10-10 09:40:00 -06:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
SDL_BITMAPORDER_NONE,
|
|
|
|
SDL_BITMAPORDER_4321,
|
|
|
|
SDL_BITMAPORDER_1234
|
2019-10-10 22:18:24 -06:00
|
|
|
} SDL_BitmapOrder;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/** Packed component order, high bit -> low bit. */
|
2019-10-10 09:40:00 -06:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
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
|
2019-10-10 22:18:24 -06:00
|
|
|
} SDL_PackedOrder;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/** Array component order, low byte -> high byte. */
|
2019-10-10 09:40:00 -06:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
SDL_ARRAYORDER_NONE,
|
|
|
|
SDL_ARRAYORDER_RGB,
|
|
|
|
SDL_ARRAYORDER_BGR,
|
2019-10-10 22:18:24 -06:00
|
|
|
} SDL_ArrayOrder;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/** Packed component layout. */
|
2019-10-10 09:40:00 -06:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
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
|
2019-10-10 22:18:24 -06:00
|
|
|
} SDL_PackedLayout;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
|
|
|
|
|
|
|
|
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
|
|
|
|
((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
|
|
|
|
((bits) << 8) | ((bytes) << 0))
|
|
|
|
|
|
|
|
#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F)
|
|
|
|
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
|
|
|
|
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
|
|
|
|
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
|
|
|
|
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
|
|
|
|
#define SDL_BYTESPERPIXEL(X) \
|
|
|
|
(SDL_ISPIXELFORMAT_FOURCC(X) ? \
|
|
|
|
((((X) == SDL_PIXELFORMAT_YUY2) || \
|
|
|
|
((X) == SDL_PIXELFORMAT_UYVY) || \
|
|
|
|
((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
|
|
|
|
|
|
|
|
#define SDL_ISPIXELFORMAT_INDEXED(format) \
|
|
|
|
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
|
|
|
|
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
|
|
|
|
|
|
|
|
#define SDL_ISPIXELFORMAT_PACKED(format) \
|
|
|
|
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
|
|
|
|
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
|
|
|
|
|
|
|
|
#define SDL_ISPIXELFORMAT_ARRAY(format) \
|
|
|
|
(!SDL_ISPIXELFORMAT_FOURCC(format) && \
|
|
|
|
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
|
|
|
|
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
|
|
|
|
|
|
|
|
#define SDL_ISPIXELFORMAT_ALPHA(format) \
|
|
|
|
((SDL_ISPIXELFORMAT_PACKED(format) && \
|
|
|
|
((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
|
|
|
|
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
|
|
|
|
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
|
2022-11-28 09:53:48 -07:00
|
|
|
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))))
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/* The flag is set to 1 because 0x1? is not in the printable ASCII range */
|
|
|
|
#define SDL_ISPIXELFORMAT_FOURCC(format) \
|
|
|
|
((format) && (SDL_PIXELFLAG(format) != 1))
|
|
|
|
|
|
|
|
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
|
2018-11-12 20:23:49 -07:00
|
|
|
typedef enum
|
2015-06-21 09:33:46 -06:00
|
|
|
{
|
|
|
|
SDL_PIXELFORMAT_UNKNOWN,
|
|
|
|
SDL_PIXELFORMAT_INDEX1LSB =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
|
|
|
|
1, 0),
|
|
|
|
SDL_PIXELFORMAT_INDEX1MSB =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
|
|
|
|
1, 0),
|
|
|
|
SDL_PIXELFORMAT_INDEX4LSB =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
|
|
|
|
4, 0),
|
|
|
|
SDL_PIXELFORMAT_INDEX4MSB =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
|
|
|
|
4, 0),
|
|
|
|
SDL_PIXELFORMAT_INDEX8 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
|
|
|
|
SDL_PIXELFORMAT_RGB332 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
|
|
|
|
SDL_PACKEDLAYOUT_332, 8, 1),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_XRGB4444 =
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 12, 2),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_RGB444 = SDL_PIXELFORMAT_XRGB4444,
|
|
|
|
SDL_PIXELFORMAT_XBGR4444 =
|
2019-11-02 16:58:52 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 12, 2),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_BGR444 = SDL_PIXELFORMAT_XBGR4444,
|
|
|
|
SDL_PIXELFORMAT_XRGB1555 =
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
|
|
|
SDL_PACKEDLAYOUT_1555, 15, 2),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_RGB555 = SDL_PIXELFORMAT_XRGB1555,
|
|
|
|
SDL_PIXELFORMAT_XBGR1555 =
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
|
|
|
SDL_PACKEDLAYOUT_1555, 15, 2),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_BGR555 = SDL_PIXELFORMAT_XBGR1555,
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_PIXELFORMAT_ARGB4444 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_RGBA4444 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_ABGR4444 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_BGRA4444 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
|
|
|
|
SDL_PACKEDLAYOUT_4444, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_ARGB1555 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
|
|
|
SDL_PACKEDLAYOUT_1555, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_RGBA5551 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
|
|
|
SDL_PACKEDLAYOUT_5551, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_ABGR1555 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
|
|
|
SDL_PACKEDLAYOUT_1555, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_BGRA5551 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
|
|
|
|
SDL_PACKEDLAYOUT_5551, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_RGB565 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
|
|
|
SDL_PACKEDLAYOUT_565, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_BGR565 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
|
|
|
SDL_PACKEDLAYOUT_565, 16, 2),
|
|
|
|
SDL_PIXELFORMAT_RGB24 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
|
|
|
|
24, 3),
|
|
|
|
SDL_PIXELFORMAT_BGR24 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
|
|
|
|
24, 3),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_XRGB8888 =
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 24, 4),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_RGB888 = SDL_PIXELFORMAT_XRGB8888,
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_PIXELFORMAT_RGBX8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 24, 4),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_XBGR8888 =
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 24, 4),
|
Fixed bug 4938 - Suggestion: rename SDL_PIXELFORMAT_BGR888 to SDL_PIXELFORMAT_XBGR8888
Ellie
I just tripped over this: stb_image when requesting 3 channels with 8-bit actually returns them as 3 bytes per pixel with no alignment, so basically 4 pixels are 12 bytes with no padding (0...2, 3...5, 6...8, and 9...11). This I would have naively expected to be called RGB888 or BGR888, since there is no "dead" unused byte as I would expect for something called e.g. RGBX8888.
However, SDL2's SDL_PIXELFORMAT_BGR888 uses 4 bytes, same as SDL_PIXELFORMAT_BGRX8888, even though the latter appears to be a longer storage format - which it isn't, internally. It's just swapped, in byte order X, B, G, R (instead of BGRX). So why isn't the macro name also swapped, as "XBGR888" instead of just "BGR888"?
I find the formats therefore named inconsistently, and unless there is a reason for this I suggest these changes:
1. deprecate SDL_PIXELFORMAT_BGR888 in favor of a new SDL_PIXELFORMAT_XBGR8888
and
2. deprecate SDL_PIXELFORMAT_RGB888 in favor of a new SDL_PIXELFORMAT_XRGB8888
2020-06-12 11:30:46 -06:00
|
|
|
SDL_PIXELFORMAT_BGR888 = SDL_PIXELFORMAT_XBGR8888,
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_PIXELFORMAT_BGRX8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 24, 4),
|
|
|
|
SDL_PIXELFORMAT_ARGB8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 32, 4),
|
|
|
|
SDL_PIXELFORMAT_RGBA8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 32, 4),
|
|
|
|
SDL_PIXELFORMAT_ABGR8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 32, 4),
|
|
|
|
SDL_PIXELFORMAT_BGRA8888 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
|
|
|
|
SDL_PACKEDLAYOUT_8888, 32, 4),
|
|
|
|
SDL_PIXELFORMAT_ARGB2101010 =
|
|
|
|
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
|
|
|
SDL_PACKEDLAYOUT_2101010, 32, 4),
|
|
|
|
|
2016-10-12 00:21:41 -06:00
|
|
|
/* Aliases for RGBA byte arrays of color data, for the current platform */
|
2016-10-12 00:19:05 -06:00
|
|
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
2016-10-12 00:21:41 -06:00
|
|
|
SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888,
|
2016-10-12 00:19:05 -06:00
|
|
|
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888,
|
|
|
|
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888,
|
|
|
|
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888,
|
|
|
|
#else
|
|
|
|
SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888,
|
|
|
|
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888,
|
|
|
|
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888,
|
|
|
|
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888,
|
|
|
|
#endif
|
|
|
|
|
2015-06-21 09:33:46 -06:00
|
|
|
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
|
|
|
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
|
|
|
|
SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
|
|
|
|
SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
|
|
|
|
SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'),
|
|
|
|
SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'),
|
|
|
|
SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */
|
2017-12-12 13:52:17 -07:00
|
|
|
SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'),
|
|
|
|
SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */
|
|
|
|
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
|
2018-11-12 20:23:49 -07:00
|
|
|
} SDL_PixelFormatEnum;
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2021-12-14 11:24:59 -07:00
|
|
|
/**
|
|
|
|
* The bits of this structure can be directly reinterpreted as an integer-packed
|
|
|
|
* color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888
|
|
|
|
* on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
|
|
|
|
*/
|
2015-06-21 09:33:46 -06:00
|
|
|
typedef struct SDL_Color
|
|
|
|
{
|
|
|
|
Uint8 r;
|
|
|
|
Uint8 g;
|
|
|
|
Uint8 b;
|
|
|
|
Uint8 a;
|
|
|
|
} SDL_Color;
|
|
|
|
#define SDL_Colour SDL_Color
|
|
|
|
|
|
|
|
typedef struct SDL_Palette
|
|
|
|
{
|
|
|
|
int ncolors;
|
|
|
|
SDL_Color *colors;
|
|
|
|
Uint32 version;
|
|
|
|
int refcount;
|
|
|
|
} SDL_Palette;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \note Everything in the pixel format structure is read-only.
|
|
|
|
*/
|
|
|
|
typedef struct SDL_PixelFormat
|
|
|
|
{
|
|
|
|
Uint32 format;
|
|
|
|
SDL_Palette *palette;
|
|
|
|
Uint8 BitsPerPixel;
|
|
|
|
Uint8 BytesPerPixel;
|
|
|
|
Uint8 padding[2];
|
|
|
|
Uint32 Rmask;
|
|
|
|
Uint32 Gmask;
|
|
|
|
Uint32 Bmask;
|
|
|
|
Uint32 Amask;
|
|
|
|
Uint8 Rloss;
|
|
|
|
Uint8 Gloss;
|
|
|
|
Uint8 Bloss;
|
|
|
|
Uint8 Aloss;
|
|
|
|
Uint8 Rshift;
|
|
|
|
Uint8 Gshift;
|
|
|
|
Uint8 Bshift;
|
|
|
|
Uint8 Ashift;
|
|
|
|
int refcount;
|
|
|
|
struct SDL_PixelFormat *next;
|
|
|
|
} SDL_PixelFormat;
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Get the human readable name of a pixel format.
|
|
|
|
*
|
|
|
|
* \param format the pixel format to query
|
|
|
|
* \returns the human readable name of the specified pixel format or
|
|
|
|
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \param format one of the SDL_PixelFormatEnum values
|
|
|
|
* \param bpp a bits per pixel value; usually 15, 16, or 32
|
|
|
|
* \param Rmask a pointer filled in with the red mask for the format
|
|
|
|
* \param Gmask a pointer filled in with the green mask for the format
|
|
|
|
* \param Bmask a pointer filled in with the blue mask for the format
|
|
|
|
* \param Amask 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.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_MasksToPixelFormatEnum
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
|
|
|
int *bpp,
|
|
|
|
Uint32 * Rmask,
|
|
|
|
Uint32 * Gmask,
|
|
|
|
Uint32 * Bmask,
|
|
|
|
Uint32 * Amask);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Convert a bpp value and RGBA masks to an enumerated pixel format.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
|
|
|
|
* possible.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \param bpp a bits per pixel value; usually 15, 16, or 32
|
|
|
|
* \param Rmask the red mask for the format
|
|
|
|
* \param Gmask the green mask for the format
|
|
|
|
* \param Bmask the blue mask for the format
|
|
|
|
* \param Amask the alpha mask for the format
|
|
|
|
* \returns one of the SDL_PixelFormatEnum values
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_PixelFormatEnumToMasks
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
|
|
|
Uint32 Rmask,
|
|
|
|
Uint32 Gmask,
|
|
|
|
Uint32 Bmask,
|
|
|
|
Uint32 Amask);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Create an SDL_PixelFormat 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.
|
|
|
|
*
|
|
|
|
* \param pixel_format one of the SDL_PixelFormatEnum values
|
|
|
|
* \returns the new SDL_PixelFormat structure or NULL on failure; call
|
|
|
|
* SDL_GetError() for more information.
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_FreeFormat
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
|
|
|
|
*
|
|
|
|
* \param format the SDL_PixelFormat structure to free
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_AllocFormat
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Create a palette structure with the specified number of color entries.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* The palette entries are initialized to white.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \param ncolors represents the number of color entries in the color palette
|
|
|
|
* \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.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_FreePalette
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Set the palette for a pixel format structure.
|
|
|
|
*
|
|
|
|
* \param format the SDL_PixelFormat structure that will use the palette
|
|
|
|
* \param palette the SDL_Palette structure that will be used
|
|
|
|
* \returns 0 on success or a negative error code on failure; call
|
|
|
|
* SDL_GetError() for more information.
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_AllocPalette
|
|
|
|
* \sa SDL_FreePalette
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
|
|
|
|
SDL_Palette *palette);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Set a range of colors in a palette.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \param palette the SDL_Palette structure to modify
|
|
|
|
* \param colors an array of SDL_Color structures to copy into the palette
|
|
|
|
* \param firstcolor the index of the first palette entry to modify
|
|
|
|
* \param ncolors 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.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_AllocPalette
|
2022-12-01 09:04:02 -07:00
|
|
|
* \sa SDL_CreateSurface
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
|
|
|
|
const SDL_Color * colors,
|
|
|
|
int firstcolor, int ncolors);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Free a palette created with SDL_AllocPalette().
|
|
|
|
*
|
|
|
|
* \param palette the SDL_Palette structure to be freed
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_AllocPalette
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* 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).
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* 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).
|
|
|
|
*
|
|
|
|
* \param format an SDL_PixelFormat structure describing the pixel format
|
|
|
|
* \param r the red component of the pixel in the range 0-255
|
|
|
|
* \param g the green component of the pixel in the range 0-255
|
|
|
|
* \param b the blue component of the pixel in the range 0-255
|
|
|
|
* \returns a pixel value
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_GetRGB
|
|
|
|
* \sa SDL_GetRGBA
|
|
|
|
* \sa SDL_MapRGBA
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
|
|
|
|
Uint8 r, Uint8 g, Uint8 b);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* 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).
|
|
|
|
*
|
|
|
|
* \param format an SDL_PixelFormat structure describing the format of the
|
|
|
|
* pixel
|
|
|
|
* \param r the red component of the pixel in the range 0-255
|
|
|
|
* \param g the green component of the pixel in the range 0-255
|
|
|
|
* \param b the blue component of the pixel in the range 0-255
|
|
|
|
* \param a the alpha component of the pixel in the range 0-255
|
|
|
|
* \returns a pixel value
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_GetRGB
|
|
|
|
* \sa SDL_GetRGBA
|
|
|
|
* \sa SDL_MapRGB
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
|
|
|
Uint8 r, Uint8 g, Uint8 b,
|
|
|
|
Uint8 a);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* Get RGB values from a pixel in the specified format.
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* 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]).
|
|
|
|
*
|
|
|
|
* \param pixel a pixel value
|
|
|
|
* \param format an SDL_PixelFormat structure describing the format of the
|
|
|
|
* pixel
|
|
|
|
* \param r a pointer filled in with the red component
|
|
|
|
* \param g a pointer filled in with the green component
|
|
|
|
* \param b a pointer filled in with the blue component
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_GetRGBA
|
|
|
|
* \sa SDL_MapRGB
|
|
|
|
* \sa SDL_MapRGBA
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
|
|
|
const SDL_PixelFormat * format,
|
|
|
|
Uint8 * r, Uint8 * g, Uint8 * b);
|
|
|
|
|
|
|
|
/**
|
2021-03-21 12:18:39 -06:00
|
|
|
* 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).
|
2015-06-21 09:33:46 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \param pixel a pixel value
|
|
|
|
* \param format an SDL_PixelFormat structure describing the format of the
|
|
|
|
* pixel
|
|
|
|
* \param r a pointer filled in with the red component
|
|
|
|
* \param g a pointer filled in with the green component
|
|
|
|
* \param b a pointer filled in with the blue component
|
|
|
|
* \param a a pointer filled in with the alpha component
|
|
|
|
*
|
2022-11-22 15:40:14 -07:00
|
|
|
* \since This function is available since SDL 3.0.0.
|
2021-10-26 19:36:05 -06:00
|
|
|
*
|
2021-03-21 12:18:39 -06:00
|
|
|
* \sa SDL_GetRGB
|
|
|
|
* \sa SDL_MapRGB
|
|
|
|
* \sa SDL_MapRGBA
|
2015-06-21 09:33:46 -06:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|
|
|
const SDL_PixelFormat * format,
|
|
|
|
Uint8 * r, Uint8 * g, Uint8 * b,
|
|
|
|
Uint8 * a);
|
|
|
|
|
|
|
|
|
|
|
|
/* Ends C function definitions when using C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-11-26 21:43:38 -07:00
|
|
|
#include <SDL3/close_code.h>
|
2015-06-21 09:33:46 -06:00
|
|
|
|
2016-11-20 22:34:54 -07:00
|
|
|
#endif /* SDL_pixels_h_ */
|
2015-06-21 09:33:46 -06:00
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|