SDL
2.0
|
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_blendmode.h"
#include "SDL_rwops.h"
#include "begin_code.h"
#include "close_code.h"
Go to the source code of this file.
Data Structures | |
struct | SDL_Surface |
A collection of pixels used in software blitting. More... | |
Surface flags | |
These are the currently supported flags for the SDL_Surface. Used internally (read-only). | |
#define | SDL_SWSURFACE 0 |
#define | SDL_PREALLOC 0x00000001 |
#define | SDL_RLEACCEL 0x00000002 |
#define | SDL_DONTFREE 0x00000004 |
#define | SDL_SIMD_ALIGNED 0x00000008 |
#define | SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) |
#define | SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) |
#define | SDL_SaveBMP(surface, file) SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) |
#define | SDL_BlitSurface SDL_UpperBlit |
#define | SDL_BlitScaled SDL_UpperBlitScaled |
enum | SDL_YUV_CONVERSION_MODE { SDL_YUV_CONVERSION_JPEG , SDL_YUV_CONVERSION_BT601 , SDL_YUV_CONVERSION_BT709 , SDL_YUV_CONVERSION_AUTOMATIC } |
The formula used for converting between YUV and RGB. More... | |
typedef int(* | SDL_blit) (struct SDL_Surface *src, SDL_Rect *srcrect, struct SDL_Surface *dst, SDL_Rect *dstrect) |
The type of function used for surface blitting functions. More... | |
SDL_Surface * | SDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) |
SDL_Surface * | SDL_CreateRGBSurfaceWithFormat (Uint32 flags, int width, int height, int depth, Uint32 format) |
SDL_Surface * | SDL_CreateRGBSurfaceFrom (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) |
SDL_Surface * | SDL_CreateRGBSurfaceWithFormatFrom (void *pixels, int width, int height, int depth, int pitch, Uint32 format) |
void | SDL_FreeSurface (SDL_Surface *surface) |
int | SDL_SetSurfacePalette (SDL_Surface *surface, SDL_Palette *palette) |
Set the palette used by a surface. More... | |
int | SDL_LockSurface (SDL_Surface *surface) |
Sets up a surface for directly accessing the pixels. More... | |
void | SDL_UnlockSurface (SDL_Surface *surface) |
SDL_Surface * | SDL_LoadBMP_RW (SDL_RWops *src, int freesrc) |
int | SDL_SaveBMP_RW (SDL_Surface *surface, SDL_RWops *dst, int freedst) |
int | SDL_SetSurfaceRLE (SDL_Surface *surface, int flag) |
Sets the RLE acceleration hint for a surface. More... | |
SDL_bool | SDL_HasSurfaceRLE (SDL_Surface *surface) |
Returns whether the surface is RLE enabled. More... | |
int | SDL_SetColorKey (SDL_Surface *surface, int flag, Uint32 key) |
Sets the color key (transparent pixel) in a blittable surface. More... | |
SDL_bool | SDL_HasColorKey (SDL_Surface *surface) |
Returns whether the surface has a color key. More... | |
int | SDL_GetColorKey (SDL_Surface *surface, Uint32 *key) |
Gets the color key (transparent pixel) in a blittable surface. More... | |
int | SDL_SetSurfaceColorMod (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) |
Set an additional color value used in blit operations. More... | |
int | SDL_GetSurfaceColorMod (SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) |
Get the additional color value used in blit operations. More... | |
int | SDL_SetSurfaceAlphaMod (SDL_Surface *surface, Uint8 alpha) |
Set an additional alpha value used in blit operations. More... | |
int | SDL_GetSurfaceAlphaMod (SDL_Surface *surface, Uint8 *alpha) |
Get the additional alpha value used in blit operations. More... | |
int | SDL_SetSurfaceBlendMode (SDL_Surface *surface, SDL_BlendMode blendMode) |
Set the blend mode used for blit operations. More... | |
int | SDL_GetSurfaceBlendMode (SDL_Surface *surface, SDL_BlendMode *blendMode) |
Get the blend mode used for blit operations. More... | |
SDL_bool | SDL_SetClipRect (SDL_Surface *surface, const SDL_Rect *rect) |
void | SDL_GetClipRect (SDL_Surface *surface, SDL_Rect *rect) |
SDL_Surface * | SDL_DuplicateSurface (SDL_Surface *surface) |
SDL_Surface * | SDL_ConvertSurface (SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags) |
SDL_Surface * | SDL_ConvertSurfaceFormat (SDL_Surface *src, Uint32 pixel_format, Uint32 flags) |
int | SDL_ConvertPixels (int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch) |
Copy a block of pixels of one format to another format. More... | |
int | SDL_FillRect (SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) |
int | SDL_FillRects (SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color) |
int | SDL_UpperBlit (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) |
int | SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) |
int | SDL_SoftStretch (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect) |
Perform a fast, low quality, stretch blit between two surfaces of the same pixel format. More... | |
int | SDL_UpperBlitScaled (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) |
int | SDL_LowerBlitScaled (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) |
void | SDL_SetYUVConversionMode (SDL_YUV_CONVERSION_MODE mode) |
Set the YUV conversion mode. More... | |
SDL_YUV_CONVERSION_MODE | SDL_GetYUVConversionMode (void) |
Get the YUV conversion mode. More... | |
SDL_YUV_CONVERSION_MODE | SDL_GetYUVConversionModeForResolution (int width, int height) |
Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC. More... | |
Header file for SDL_Surface definition and management functions.
Definition in file SDL_surface.h.
#define SDL_BlitScaled SDL_UpperBlitScaled |
Definition at line 522 of file SDL_surface.h.
#define SDL_BlitSurface SDL_UpperBlit |
Performs a fast blit from the source surface to the destination surface.
This assumes that the source and destination rectangles are the same size. If either srcrect
or dstrect
are NULL, the entire surface (src
or dst
) is copied. The final blit rectangles are saved in srcrect
and dstrect
after all clipping is performed.
The blit function should not be called on a locked surface.
The blit semantics for surfaces with and without blending and colorkey are defined as follows:
RGBA->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. RGB->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB, set destination alpha to source per-surface alpha value. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key. RGBA->RGBA: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source alpha-channel and per-surface alpha) SDL_SRCCOLORKEY ignored. Source surface blend mode set to SDL_BLENDMODE_NONE: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source color key, ignoring alpha in the comparison. RGB->RGB: Source surface blend mode set to SDL_BLENDMODE_BLEND: alpha-blend (using the source per-surface alpha) Source surface blend mode set to SDL_BLENDMODE_NONE: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source color key.
You should call SDL_BlitSurface() unless you know exactly how SDL blitting works internally and how to use the other blit functions.
Definition at line 493 of file SDL_surface.h.
#define SDL_DONTFREE 0x00000004 |
Surface is referenced internally
Definition at line 55 of file SDL_surface.h.
#define SDL_LoadBMP | ( | file | ) | SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) |
#define SDL_MUSTLOCK | ( | S | ) | (((S)->flags & SDL_RLEACCEL) != 0) |
Evaluates to true if the surface needs to be locked before access.
Definition at line 62 of file SDL_surface.h.
#define SDL_PREALLOC 0x00000001 |
Surface uses preallocated memory
Definition at line 53 of file SDL_surface.h.
#define SDL_RLEACCEL 0x00000002 |
Surface is RLE encoded
Definition at line 54 of file SDL_surface.h.
#define SDL_SaveBMP | ( | surface, | |
file | |||
) | SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) |
#define SDL_SIMD_ALIGNED 0x00000008 |
Surface uses aligned memory
Definition at line 56 of file SDL_surface.h.
#define SDL_SWSURFACE 0 |
Just here for compatibility
Definition at line 52 of file SDL_surface.h.
typedef int( * SDL_blit) (struct SDL_Surface *src, SDL_Rect *srcrect, struct SDL_Surface *dst, SDL_Rect *dstrect) |
The type of function used for surface blitting functions.
Definition at line 100 of file SDL_surface.h.
The formula used for converting between YUV and RGB.
Definition at line 106 of file SDL_surface.h.
int SDL_ConvertPixels | ( | int | width, |
int | height, | ||
Uint32 | src_format, | ||
const void * | src, | ||
int | src_pitch, | ||
Uint32 | dst_format, | ||
void * | dst, | ||
int | dst_pitch | ||
) |
Copy a block of pixels of one format to another format.
SDL_Surface* SDL_ConvertSurface | ( | SDL_Surface * | src, |
const SDL_PixelFormat * | fmt, | ||
Uint32 | flags | ||
) |
Creates a new surface of the specified format, and then copies and maps the given surface to it so the blit of the converted surface will be as fast as possible. If this function fails, it returns NULL.
The flags
parameter is passed to SDL_CreateRGBSurface() and has those semantics. You can also pass SDL_RLEACCEL in the flags parameter and SDL will try to RLE accelerate colorkey and alpha blits in the resulting surface.
SDL_Surface* SDL_ConvertSurfaceFormat | ( | SDL_Surface * | src, |
Uint32 | pixel_format, | ||
Uint32 | flags | ||
) |
SDL_Surface* SDL_CreateRGBSurface | ( | Uint32 | flags, |
int | width, | ||
int | height, | ||
int | depth, | ||
Uint32 | Rmask, | ||
Uint32 | Gmask, | ||
Uint32 | Bmask, | ||
Uint32 | Amask | ||
) |
Allocate and free an RGB surface.
If the depth is 4 or 8 bits, an empty palette is allocated for the surface. If the depth is greater than 8 bits, the pixel format is set using the flags '[RGB]mask'.
If the function runs out of memory, it will return NULL.
flags | The flags are obsolete and should be set to 0. |
width | The width in pixels of the surface to create. |
height | The height in pixels of the surface to create. |
depth | The depth in bits of the surface to create. |
Rmask | The red mask of the surface to create. |
Gmask | The green mask of the surface to create. |
Bmask | The blue mask of the surface to create. |
Amask | The alpha mask of the surface to create. |
SDL_Surface* SDL_CreateRGBSurfaceFrom | ( | void * | pixels, |
int | width, | ||
int | height, | ||
int | depth, | ||
int | pitch, | ||
Uint32 | Rmask, | ||
Uint32 | Gmask, | ||
Uint32 | Bmask, | ||
Uint32 | Amask | ||
) |
SDL_Surface* SDL_CreateRGBSurfaceWithFormat | ( | Uint32 | flags, |
int | width, | ||
int | height, | ||
int | depth, | ||
Uint32 | format | ||
) |
SDL_Surface* SDL_CreateRGBSurfaceWithFormatFrom | ( | void * | pixels, |
int | width, | ||
int | height, | ||
int | depth, | ||
int | pitch, | ||
Uint32 | format | ||
) |
SDL_Surface* SDL_DuplicateSurface | ( | SDL_Surface * | surface | ) |
int SDL_FillRect | ( | SDL_Surface * | dst, |
const SDL_Rect * | rect, | ||
Uint32 | color | ||
) |
Performs a fast fill of the given rectangle with color
.
If rect
is NULL, the whole surface will be filled with color
.
The color should be a pixel of the format used by the surface, and can be generated by the SDL_MapRGB() function.
int SDL_FillRects | ( | SDL_Surface * | dst, |
const SDL_Rect * | rects, | ||
int | count, | ||
Uint32 | color | ||
) |
void SDL_FreeSurface | ( | SDL_Surface * | surface | ) |
void SDL_GetClipRect | ( | SDL_Surface * | surface, |
SDL_Rect * | rect | ||
) |
Gets the clipping rectangle for the destination surface in a blit.
rect
must be a pointer to a valid rectangle which will be filled with the correct values.
int SDL_GetColorKey | ( | SDL_Surface * | surface, |
Uint32 * | key | ||
) |
Gets the color key (transparent pixel) in a blittable surface.
surface | The surface to update |
key | A pointer filled in with the transparent pixel in the native surface format |
int SDL_GetSurfaceAlphaMod | ( | SDL_Surface * | surface, |
Uint8 * | alpha | ||
) |
Get the additional alpha value used in blit operations.
surface | The surface to query. |
alpha | A pointer filled in with the current alpha value. |
int SDL_GetSurfaceBlendMode | ( | SDL_Surface * | surface, |
SDL_BlendMode * | blendMode | ||
) |
Get the blend mode used for blit operations.
surface | The surface to query. |
blendMode | A pointer filled in with the current blend mode. |
int SDL_GetSurfaceColorMod | ( | SDL_Surface * | surface, |
Uint8 * | r, | ||
Uint8 * | g, | ||
Uint8 * | b | ||
) |
Get the additional color value used in blit operations.
surface | The surface to query. |
r | A pointer filled in with the current red color value. |
g | A pointer filled in with the current green color value. |
b | A pointer filled in with the current blue color value. |
SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode | ( | void | ) |
Get the YUV conversion mode.
SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionModeForResolution | ( | int | width, |
int | height | ||
) |
Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC.
SDL_bool SDL_HasColorKey | ( | SDL_Surface * | surface | ) |
Returns whether the surface has a color key.
SDL_bool SDL_HasSurfaceRLE | ( | SDL_Surface * | surface | ) |
Returns whether the surface is RLE enabled.
SDL_Surface* SDL_LoadBMP_RW | ( | SDL_RWops * | src, |
int | freesrc | ||
) |
Load a surface from a seekable SDL data stream (memory or file).
If freesrc
is non-zero, the stream will be closed after being read.
The new surface should be freed with SDL_FreeSurface().
int SDL_LockSurface | ( | SDL_Surface * | surface | ) |
Sets up a surface for directly accessing the pixels.
Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to and read from surface->pixels
, using the pixel format stored in surface->format
. Once you are done accessing the surface, you should use SDL_UnlockSurface() to release it.
Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time.
SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
int SDL_LowerBlit | ( | SDL_Surface * | src, |
SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is a semi-private blit function and it performs low-level surface blitting only.
int SDL_LowerBlitScaled | ( | SDL_Surface * | src, |
SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is a semi-private blit function and it performs low-level surface scaled blitting only.
int SDL_SaveBMP_RW | ( | SDL_Surface * | surface, |
SDL_RWops * | dst, | ||
int | freedst | ||
) |
Save a surface to a seekable SDL data stream (memory or file).
Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the BMP directly. Other RGB formats with 8-bit or higher get converted to a 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit surface before they are saved. YUV and paletted 1-bit and 4-bit formats are not supported.
If freedst
is non-zero, the stream will be closed after being written.
SDL_bool SDL_SetClipRect | ( | SDL_Surface * | surface, |
const SDL_Rect * | rect | ||
) |
Sets the clipping rectangle for the destination surface in a blit.
If the clip rectangle is NULL, clipping will be disabled.
If the clip rectangle doesn't intersect the surface, the function will return SDL_FALSE and blits will be completely clipped. Otherwise the function returns SDL_TRUE and blits to the surface will be clipped to the intersection of the surface area and the clipping rectangle.
Note that blits are automatically clipped to the edges of the source and destination surfaces.
int SDL_SetColorKey | ( | SDL_Surface * | surface, |
int | flag, | ||
Uint32 | key | ||
) |
Sets the color key (transparent pixel) in a blittable surface.
surface | The surface to update |
flag | Non-zero to enable colorkey and 0 to disable colorkey |
key | The transparent pixel in the native surface format |
You can pass SDL_RLEACCEL to enable RLE accelerated blits.
int SDL_SetSurfaceAlphaMod | ( | SDL_Surface * | surface, |
Uint8 | alpha | ||
) |
Set an additional alpha value used in blit operations.
surface | The surface to update. |
alpha | The alpha value multiplied into blit operations. |
int SDL_SetSurfaceBlendMode | ( | SDL_Surface * | surface, |
SDL_BlendMode | blendMode | ||
) |
Set the blend mode used for blit operations.
surface | The surface to update. |
blendMode | SDL_BlendMode to use for blit blending. |
int SDL_SetSurfaceColorMod | ( | SDL_Surface * | surface, |
Uint8 | r, | ||
Uint8 | g, | ||
Uint8 | b | ||
) |
Set an additional color value used in blit operations.
surface | The surface to update. |
r | The red color value multiplied into blit operations. |
g | The green color value multiplied into blit operations. |
b | The blue color value multiplied into blit operations. |
int SDL_SetSurfacePalette | ( | SDL_Surface * | surface, |
SDL_Palette * | palette | ||
) |
Set the palette used by a surface.
int SDL_SetSurfaceRLE | ( | SDL_Surface * | surface, |
int | flag | ||
) |
Sets the RLE acceleration hint for a surface.
void SDL_SetYUVConversionMode | ( | SDL_YUV_CONVERSION_MODE | mode | ) |
Set the YUV conversion mode.
int SDL_SoftStretch | ( | SDL_Surface * | src, |
const SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
const SDL_Rect * | dstrect | ||
) |
Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
void SDL_UnlockSurface | ( | SDL_Surface * | surface | ) |
int SDL_UpperBlit | ( | SDL_Surface * | src, |
const SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is the public blit function, SDL_BlitSurface(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlit()
int SDL_UpperBlitScaled | ( | SDL_Surface * | src, |
const SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is the public scaled blit function, SDL_BlitScaled(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlitScaled()