arsa  2.7
SDL_surface.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2019 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
40 extern "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 
70 typedef struct SDL_Surface
71 {
74  int w, h;
75  int pitch;
76  void *pixels;
79  void *userdata;
82  int locked;
83  void *lock_data;
89  struct SDL_BlitMap *map;
92  int refcount;
93 } SDL_Surface;
94 
98 typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
99  struct SDL_Surface * dst, SDL_Rect * dstrect);
100 
104 typedef enum
105 {
111 
131  (Uint32 flags, int width, int height, int depth,
132  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
133 
134 /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
136  (Uint32 flags, int width, int height, int depth, Uint32 format);
137 
139  int width,
140  int height,
141  int depth,
142  int pitch,
143  Uint32 Rmask,
144  Uint32 Gmask,
145  Uint32 Bmask,
146  Uint32 Amask);
148  (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
149 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
150 
159  SDL_Palette * palette);
160 
180 extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
182 extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
183 
194  int freesrc);
195 
201 #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
202 
217  (SDL_Surface * surface, SDL_RWops * dst, int freedst);
218 
224 #define SDL_SaveBMP(surface, file) \
225  SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
226 
235 extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
236  int flag);
237 
249 extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
250  int flag, Uint32 key);
251 
258 
269 extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
270  Uint32 * key);
271 
285  Uint8 r, Uint8 g, Uint8 b);
286 
287 
301  Uint8 * r, Uint8 * g,
302  Uint8 * b);
303 
315  Uint8 alpha);
316 
328  Uint8 * alpha);
329 
341  SDL_BlendMode blendMode);
342 
354  SDL_BlendMode *blendMode);
355 
370  const SDL_Rect * rect);
371 
378 extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
379  SDL_Rect * rect);
380 
381 /*
382  * Creates a new surface identical to the existing surface
383  */
385 
397  (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
399  (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
400 
406 extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
407  Uint32 src_format,
408  const void * src, int src_pitch,
409  Uint32 dst_format,
410  void * dst, int dst_pitch);
411 
422 extern DECLSPEC int SDLCALL SDL_FillRect
423  (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
424 extern DECLSPEC int SDLCALL SDL_FillRects
425  (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
426 
484 #define SDL_BlitSurface SDL_UpperBlit
485 
490 extern DECLSPEC int SDLCALL SDL_UpperBlit
491  (SDL_Surface * src, const SDL_Rect * srcrect,
492  SDL_Surface * dst, SDL_Rect * dstrect);
493 
498 extern DECLSPEC int SDLCALL SDL_LowerBlit
499  (SDL_Surface * src, SDL_Rect * srcrect,
500  SDL_Surface * dst, SDL_Rect * dstrect);
501 
509  const SDL_Rect * srcrect,
510  SDL_Surface * dst,
511  const SDL_Rect * dstrect);
512 
513 #define SDL_BlitScaled SDL_UpperBlitScaled
514 
520  (SDL_Surface * src, const SDL_Rect * srcrect,
521  SDL_Surface * dst, SDL_Rect * dstrect);
522 
528  (SDL_Surface * src, SDL_Rect * srcrect,
529  SDL_Surface * dst, SDL_Rect * dstrect);
530 
535 
540 
545 
546 /* Ends C function definitions when using C++ */
547 #ifdef __cplusplus
548 }
549 #endif
550 #include "close_code.h"
551 
552 #endif /* SDL_surface_h_ */
553 
554 /* vi: set ts=4 sw=4 expandtab: */
GLenum GLenum dst
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
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_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
SDL_YUV_CONVERSION_MODE
The formula used for converting between YUV and RGB.
Definition: SDL_surface.h:104
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
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)
Copy a block of pixels of one format to another format.
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_bool
Definition: SDL_stdinc.h:161
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
struct SDL_Surface SDL_Surface
A collection of pixels used in software blitting.
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode)
Set the YUV conversion mode.
#define DECLSPEC
Definition: begin_code.h:74
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
uint32_t Uint32
Definition: SDL_stdinc.h:203
#define SDLCALL
Definition: begin_code.h:89
DECLSPEC int SDLCALL SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
GLfloat GLfloat GLfloat alpha
DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void)
Get the YUV conversion mode.
DECLSPEC int SDLCALL SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
Uint32 flags
Definition: SDL_surface.h:72
DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
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:98
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
SDL_AudioFormat format
Definition: SDL_audio.h:194
DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface *surface)
struct SDL_BlitMap * map
Definition: SDL_surface.h:89
void * pixels
Definition: SDL_surface.h:76
DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
GLenum mode
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags)
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
SDL_Rect clip_rect
Definition: SDL_surface.h:86
DECLSPEC int SDLCALL SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *src, Uint32 pixel_format, Uint32 flags)
DECLSPEC int SDLCALL SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
SDL_PixelFormat * format
Definition: SDL_surface.h:73
GLint GLint GLsizei GLsizei GLsizei depth
Definition: SDL_opengl.h:1572
GLboolean GLboolean GLboolean b
DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height)
Get the YUV conversion mode, returning the correct mode for the resolution when the current conversio...
GLuint color
DECLSPEC int SDLCALL SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
GLbitfield flags
DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface *surface)
Returns whether the surface has a color key.
uint8_t Uint8
Definition: SDL_stdinc.h:179
GLboolean GLboolean g
GLenum src
DECLSPEC int SDLCALL SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color)
void * lock_data
Definition: SDL_surface.h:83
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
void * userdata
Definition: SDL_surface.h:79
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77
DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
DECLSPEC int SDLCALL 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.
DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.