My Project
Loading...
Searching...
No Matches
SDL_surface.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
28#ifndef SDL_surface_h_
29#define SDL_surface_h_
30
31#include "SDL_stdinc.h"
32#include "SDL_pixels.h"
33#include "SDL_rect.h"
34#include "SDL_blendmode.h"
35#include "SDL_rwops.h"
36
37#include "begin_code.h"
38/* Set up for C function definitions, even when using C++ */
39#ifdef __cplusplus
40extern "C" {
41#endif
42
51/* @{ */
52#define SDL_SWSURFACE 0
53#define SDL_PREALLOC 0x00000001
54#define SDL_RLEACCEL 0x00000002
55#define SDL_DONTFREE 0x00000004
56#define SDL_SIMD_ALIGNED 0x00000008
57/* @} *//* Surface flags */
58
62#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
63
64typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
65
72typedef struct SDL_Surface
73{
74 Uint32 flags;
76 int w, h;
77 int pitch;
78 void *pixels;
81 void *userdata;
84 int locked;
93 SDL_BlitMap *map;
98
102typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
103 struct SDL_Surface * dst, SDL_Rect * dstrect);
104
108typedef enum
109{
115
160extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
161 (Uint32 flags, int width, int height, int depth,
162 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
163
164
165/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
166
189 (Uint32 flags, int width, int height, int depth, Uint32 format);
190
219extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
220 int width,
221 int height,
222 int depth,
223 int pitch,
224 Uint32 Rmask,
225 Uint32 Gmask,
226 Uint32 Bmask,
227 Uint32 Amask);
228
229/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
230
258 (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
259
274extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
275
288extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
289 SDL_Palette * palette);
290
312extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
313
323extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
324
347extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
348 int freesrc);
349
355#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
356
377extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
378 (SDL_Surface * surface, SDL_RWops * dst, int freedst);
379
385#define SDL_SaveBMP(surface, file) \
386 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
387
405extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
406 int flag);
407
420extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
421
446extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
447 int flag, Uint32 key);
448
462extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
463
482extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
483 Uint32 * key);
484
506extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
507 Uint8 r, Uint8 g, Uint8 b);
508
509
525extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
526 Uint8 * r, Uint8 * g,
527 Uint8 * b);
528
547extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
548 Uint8 alpha);
549
563extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
564 Uint8 * alpha);
565
582extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
583 SDL_BlendMode blendMode);
584
597extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
598 SDL_BlendMode *blendMode);
599
620extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
621 const SDL_Rect * rect);
622
639extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
640 SDL_Rect * rect);
641
642/*
643 * Creates a new surface identical to the existing surface.
644 *
645 * The returned surface should be freed with SDL_FreeSurface().
646 *
647 * \param surface the surface to duplicate.
648 * \returns a copy of the surface, or NULL on failure; call SDL_GetError() for
649 * more information.
650 */
651extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface);
652
675extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
676 (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
677
700extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
701 (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
702
719extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
720 Uint32 src_format,
721 const void * src, int src_pitch,
722 Uint32 dst_format,
723 void * dst, int dst_pitch);
724
745extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
746 Uint32 src_format,
747 const void * src, int src_pitch,
748 Uint32 dst_format,
749 void * dst, int dst_pitch);
750
774extern DECLSPEC int SDLCALL SDL_FillRect
775 (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
776
800extern DECLSPEC int SDLCALL SDL_FillRects
801 (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
802
803/* !!! FIXME: merge this documentation with the wiki */
861#define SDL_BlitSurface SDL_UpperBlit
862
873extern DECLSPEC int SDLCALL SDL_UpperBlit
874 (SDL_Surface * src, const SDL_Rect * srcrect,
875 SDL_Surface * dst, SDL_Rect * dstrect);
876
899extern DECLSPEC int SDLCALL SDL_LowerBlit
900 (SDL_Surface * src, SDL_Rect * srcrect,
901 SDL_Surface * dst, SDL_Rect * dstrect);
902
903
912extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
913 const SDL_Rect * srcrect,
914 SDL_Surface * dst,
915 const SDL_Rect * dstrect);
916
922extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
923 const SDL_Rect * srcrect,
924 SDL_Surface * dst,
925 const SDL_Rect * dstrect);
926
927
928#define SDL_BlitScaled SDL_UpperBlitScaled
929
940extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
941 (SDL_Surface * src, const SDL_Rect * srcrect,
942 SDL_Surface * dst, SDL_Rect * dstrect);
943
963extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
964 (SDL_Surface * src, SDL_Rect * srcrect,
965 SDL_Surface * dst, SDL_Rect * dstrect);
966
972extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
973
980
987extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
988
989/* Ends C function definitions when using C++ */
990#ifdef __cplusplus
991}
992#endif
993#include "close_code.h"
994
995#endif /* SDL_surface_h_ */
996
997/* vi: set ts=4 sw=4 expandtab: */
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:41
DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
SDL_YUV_CONVERSION_MODE
The formula used for converting between YUV and RGB.
Definition: SDL_surface.h:109
@ SDL_YUV_CONVERSION_BT601
Definition: SDL_surface.h:111
@ SDL_YUV_CONVERSION_JPEG
Definition: SDL_surface.h:110
@ SDL_YUV_CONVERSION_BT709
Definition: SDL_surface.h:112
@ SDL_YUV_CONVERSION_AUTOMATIC
Definition: SDL_surface.h:113
DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height)
DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface *surface)
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *src, Uint32 pixel_format, Uint32 flags)
DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode)
DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags)
DECLSPEC int SDLCALL SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
DECLSPEC int SDLCALL SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color)
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
DECLSPEC int SDLCALL SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
DECLSPEC int SDLCALL SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
int(SDLCALL * 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: SDL_surface.h:102
DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
Definition: SDL_pixels.h:319
Definition: SDL_pixels.h:330
Definition: SDL_rwops.h:53
Definition: SDL_rect.h:79
A collection of pixels used in software blitting.
Definition: SDL_surface.h:73
Uint32 flags
Definition: SDL_surface.h:74
int pitch
Definition: SDL_surface.h:77
SDL_BlitMap * map
Definition: SDL_surface.h:93
int h
Definition: SDL_surface.h:76
int locked
Definition: SDL_surface.h:84
int refcount
Definition: SDL_surface.h:96
SDL_PixelFormat * format
Definition: SDL_surface.h:75
void * pixels
Definition: SDL_surface.h:78
void * list_blitmap
Definition: SDL_surface.h:87
SDL_Rect clip_rect
Definition: SDL_surface.h:90
void * userdata
Definition: SDL_surface.h:81