My Project
SDL_surface.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 {
72  Uint32 flags;
74  int w, h;
75  int pitch;
76  void *pixels;
79  void *userdata;
82  int locked;
85  void *list_blitmap;
91  struct SDL_BlitMap *map;
94  int refcount;
96 
100 typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
101  struct SDL_Surface * dst, SDL_Rect * dstrect);
102 
106 typedef enum
107 {
113 
132 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
133  (Uint32 flags, int width, int height, int depth,
134  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
135 
136 /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
137 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
138  (Uint32 flags, int width, int height, int depth, Uint32 format);
139 
140 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
141  int width,
142  int height,
143  int depth,
144  int pitch,
145  Uint32 Rmask,
146  Uint32 Gmask,
147  Uint32 Bmask,
148  Uint32 Amask);
149 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
150  (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
151 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
152 
160 extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
161  SDL_Palette * palette);
162 
182 extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
184 extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
185 
195 extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
196  int freesrc);
197 
203 #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
204 
218 extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
219  (SDL_Surface * surface, SDL_RWops * dst, int freedst);
220 
226 #define SDL_SaveBMP(surface, file) \
227  SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
228 
237 extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
238  int flag);
239 
245 extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
246 
258 extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
259  int flag, Uint32 key);
260 
266 extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
267 
278 extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
279  Uint32 * key);
280 
293 extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
294  Uint8 r, Uint8 g, Uint8 b);
295 
296 
309 extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
310  Uint8 * r, Uint8 * g,
311  Uint8 * b);
312 
323 extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
324  Uint8 alpha);
325 
336 extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
337  Uint8 * alpha);
338 
349 extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
350  SDL_BlendMode blendMode);
351 
362 extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
363  SDL_BlendMode *blendMode);
364 
378 extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
379  const SDL_Rect * rect);
380 
387 extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
388  SDL_Rect * rect);
389 
390 /*
391  * Creates a new surface identical to the existing surface
392  */
393 extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface);
394 
405 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
406  (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
407 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
408  (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
409 
415 extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
416  Uint32 src_format,
417  const void * src, int src_pitch,
418  Uint32 dst_format,
419  void * dst, int dst_pitch);
420 
431 extern DECLSPEC int SDLCALL SDL_FillRect
432  (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
433 extern DECLSPEC int SDLCALL SDL_FillRects
434  (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
435 
493 #define SDL_BlitSurface SDL_UpperBlit
494 
499 extern DECLSPEC int SDLCALL SDL_UpperBlit
500  (SDL_Surface * src, const SDL_Rect * srcrect,
501  SDL_Surface * dst, SDL_Rect * dstrect);
502 
507 extern DECLSPEC int SDLCALL SDL_LowerBlit
508  (SDL_Surface * src, SDL_Rect * srcrect,
509  SDL_Surface * dst, SDL_Rect * dstrect);
510 
517 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
518  const SDL_Rect * srcrect,
519  SDL_Surface * dst,
520  const SDL_Rect * dstrect);
521 
522 #define SDL_BlitScaled SDL_UpperBlitScaled
523 
528 extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
529  (SDL_Surface * src, const SDL_Rect * srcrect,
530  SDL_Surface * dst, SDL_Rect * dstrect);
531 
536 extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
537  (SDL_Surface * src, SDL_Rect * srcrect,
538  SDL_Surface * dst, SDL_Rect * dstrect);
539 
543 extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
544 
548 extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
549 
553 extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
554 
555 /* Ends C function definitions when using C++ */
556 #ifdef __cplusplus
557 }
558 #endif
559 #include "close_code.h"
560 
561 #endif /* SDL_surface_h_ */
562 
563 /* vi: set ts=4 sw=4 expandtab: */
SDL_PixelFormat
Definition: SDL_pixels.h:325
SDL_LowerBlit
DECLSPEC int SDLCALL SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:75
SDL_Surface::map
struct SDL_BlitMap * map
Definition: SDL_surface.h:91
SDL_Surface::clip_rect
SDL_Rect clip_rect
Definition: SDL_surface.h:88
SDL_LockSurface
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
SDL_GetSurfaceAlphaMod
DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
SDL_YUV_CONVERSION_JPEG
@ SDL_YUV_CONVERSION_JPEG
Definition: SDL_surface.h:108
SDL_blendmode.h
SDL_Surface
struct SDL_Surface SDL_Surface
A collection of pixels used in software blitting.
SDL_Surface::list_blitmap
void * list_blitmap
Definition: SDL_surface.h:85
SDL_YUV_CONVERSION_BT709
@ SDL_YUV_CONVERSION_BT709
Definition: SDL_surface.h:110
SDL_UpperBlitScaled
DECLSPEC int SDLCALL SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_UpperBlit
DECLSPEC int SDLCALL SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_GetColorKey
DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
SDL_Surface::h
int h
Definition: SDL_surface.h:74
SDL_SaveBMP_RW
DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
SDL_Surface::format
SDL_PixelFormat * format
Definition: SDL_surface.h:73
SDL_GetClipRect
DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
SDL_stdinc.h
SDL_RWops
Definition: SDL_rwops.h:53
SDL_SetSurfaceRLE
DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
close_code.h
SDL_GetYUVConversionMode
DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void)
Get the YUV conversion mode.
begin_code.h
SDL_CreateRGBSurface
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
SDL_ConvertSurface
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags)
SDL_FillRect
DECLSPEC int SDLCALL SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
SDL_SetColorKey
DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
SDL_LoadBMP_RW
DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
SDL_Surface::flags
Uint32 flags
Definition: SDL_surface.h:72
SDL_Rect
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
SDL_SetSurfaceAlphaMod
DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
SDL_Surface::userdata
void * userdata
Definition: SDL_surface.h:79
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:76
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:41
SDL_pixels.h
SDL_SetSurfacePalette
DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
SDL_GetSurfaceBlendMode
DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.
SDL_SetSurfaceColorMod
DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
SDL_blit
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:100
SDL_HasColorKey
DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface *surface)
Returns whether the surface has a color key.
SDL_YUV_CONVERSION_AUTOMATIC
@ SDL_YUV_CONVERSION_AUTOMATIC
Definition: SDL_surface.h:111
SDL_HasSurfaceRLE
DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface *surface)
Returns whether the surface is RLE enabled.
SDL_rwops.h
SDL_LowerBlitScaled
DECLSPEC int SDLCALL SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_GetYUVConversionModeForResolution
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...
SDL_SoftStretch
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.
SDL_Palette
Definition: SDL_pixels.h:314
SDL_ConvertPixels
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.
SDL_YUV_CONVERSION_MODE
SDL_YUV_CONVERSION_MODE
The formula used for converting between YUV and RGB.
Definition: SDL_surface.h:107
SDL_Surface::refcount
int refcount
Definition: SDL_surface.h:94
SDL_Surface::locked
int locked
Definition: SDL_surface.h:82
SDL_GetSurfaceColorMod
DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
SDL_SetYUVConversionMode
DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode)
Set the YUV conversion mode.
SDL_rect.h
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:71
SDL_UnlockSurface
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
SDL_YUV_CONVERSION_BT601
@ SDL_YUV_CONVERSION_BT601
Definition: SDL_surface.h:109
SDL_SetClipRect
DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
SDL_SetSurfaceBlendMode
DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.