SDL Library
SDL_surface.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | /** |
miruga27 | 0:7fb6877b5d7c | 23 | * \file SDL_surface.h |
miruga27 | 0:7fb6877b5d7c | 24 | * |
miruga27 | 0:7fb6877b5d7c | 25 | * Header file for ::SDL_Surface definition and management functions. |
miruga27 | 0:7fb6877b5d7c | 26 | */ |
miruga27 | 0:7fb6877b5d7c | 27 | |
miruga27 | 0:7fb6877b5d7c | 28 | #ifndef _SDL_surface_h |
miruga27 | 0:7fb6877b5d7c | 29 | #define _SDL_surface_h |
miruga27 | 0:7fb6877b5d7c | 30 | |
miruga27 | 0:7fb6877b5d7c | 31 | #include "SDL_stdinc.h" |
miruga27 | 0:7fb6877b5d7c | 32 | #include "SDL_pixels.h" |
miruga27 | 0:7fb6877b5d7c | 33 | #include "SDL_rect.h" |
miruga27 | 0:7fb6877b5d7c | 34 | #include "SDL_blendmode.h" |
miruga27 | 0:7fb6877b5d7c | 35 | #include "SDL_rwops.h" |
miruga27 | 0:7fb6877b5d7c | 36 | |
miruga27 | 0:7fb6877b5d7c | 37 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 38 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 39 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 40 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 41 | #endif |
miruga27 | 0:7fb6877b5d7c | 42 | |
miruga27 | 0:7fb6877b5d7c | 43 | /** |
miruga27 | 0:7fb6877b5d7c | 44 | * \name Surface flags |
miruga27 | 0:7fb6877b5d7c | 45 | * |
miruga27 | 0:7fb6877b5d7c | 46 | * These are the currently supported flags for the ::SDL_Surface. |
miruga27 | 0:7fb6877b5d7c | 47 | * |
miruga27 | 0:7fb6877b5d7c | 48 | * \internal |
miruga27 | 0:7fb6877b5d7c | 49 | * Used internally (read-only). |
miruga27 | 0:7fb6877b5d7c | 50 | */ |
miruga27 | 0:7fb6877b5d7c | 51 | /* @{ */ |
miruga27 | 0:7fb6877b5d7c | 52 | #define SDL_SWSURFACE 0 /**< Just here for compatibility */ |
miruga27 | 0:7fb6877b5d7c | 53 | #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ |
miruga27 | 0:7fb6877b5d7c | 54 | #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ |
miruga27 | 0:7fb6877b5d7c | 55 | #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ |
miruga27 | 0:7fb6877b5d7c | 56 | /* @} *//* Surface flags */ |
miruga27 | 0:7fb6877b5d7c | 57 | |
miruga27 | 0:7fb6877b5d7c | 58 | /** |
miruga27 | 0:7fb6877b5d7c | 59 | * Evaluates to true if the surface needs to be locked before access. |
miruga27 | 0:7fb6877b5d7c | 60 | */ |
miruga27 | 0:7fb6877b5d7c | 61 | #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) |
miruga27 | 0:7fb6877b5d7c | 62 | |
miruga27 | 0:7fb6877b5d7c | 63 | /** |
miruga27 | 0:7fb6877b5d7c | 64 | * \brief A collection of pixels used in software blitting. |
miruga27 | 0:7fb6877b5d7c | 65 | * |
miruga27 | 0:7fb6877b5d7c | 66 | * \note This structure should be treated as read-only, except for \c pixels, |
miruga27 | 0:7fb6877b5d7c | 67 | * which, if not NULL, contains the raw pixel data for the surface. |
miruga27 | 0:7fb6877b5d7c | 68 | */ |
miruga27 | 0:7fb6877b5d7c | 69 | typedef struct SDL_Surface |
miruga27 | 0:7fb6877b5d7c | 70 | { |
miruga27 | 0:7fb6877b5d7c | 71 | Uint32 flags; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 72 | SDL_PixelFormat *format; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 73 | int w, h; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 74 | int pitch; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 75 | void *pixels; /**< Read-write */ |
miruga27 | 0:7fb6877b5d7c | 76 | |
miruga27 | 0:7fb6877b5d7c | 77 | /** Application data associated with the surface */ |
miruga27 | 0:7fb6877b5d7c | 78 | void *userdata; /**< Read-write */ |
miruga27 | 0:7fb6877b5d7c | 79 | |
miruga27 | 0:7fb6877b5d7c | 80 | /** information needed for surfaces requiring locks */ |
miruga27 | 0:7fb6877b5d7c | 81 | int locked; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 82 | void *lock_data; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 83 | |
miruga27 | 0:7fb6877b5d7c | 84 | /** clipping information */ |
miruga27 | 0:7fb6877b5d7c | 85 | SDL_Rect clip_rect; /**< Read-only */ |
miruga27 | 0:7fb6877b5d7c | 86 | |
miruga27 | 0:7fb6877b5d7c | 87 | /** info for fast blit mapping to other surfaces */ |
miruga27 | 0:7fb6877b5d7c | 88 | struct SDL_BlitMap *map; /**< Private */ |
miruga27 | 0:7fb6877b5d7c | 89 | |
miruga27 | 0:7fb6877b5d7c | 90 | /** Reference count -- used when freeing surface */ |
miruga27 | 0:7fb6877b5d7c | 91 | int refcount; /**< Read-mostly */ |
miruga27 | 0:7fb6877b5d7c | 92 | } SDL_Surface; |
miruga27 | 0:7fb6877b5d7c | 93 | |
miruga27 | 0:7fb6877b5d7c | 94 | /** |
miruga27 | 0:7fb6877b5d7c | 95 | * \brief The type of function used for surface blitting functions. |
miruga27 | 0:7fb6877b5d7c | 96 | */ |
miruga27 | 0:7fb6877b5d7c | 97 | typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 98 | struct SDL_Surface * dst, SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 99 | |
miruga27 | 0:7fb6877b5d7c | 100 | /** |
miruga27 | 0:7fb6877b5d7c | 101 | * Allocate and free an RGB surface. |
miruga27 | 0:7fb6877b5d7c | 102 | * |
miruga27 | 0:7fb6877b5d7c | 103 | * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. |
miruga27 | 0:7fb6877b5d7c | 104 | * If the depth is greater than 8 bits, the pixel format is set using the |
miruga27 | 0:7fb6877b5d7c | 105 | * flags '[RGB]mask'. |
miruga27 | 0:7fb6877b5d7c | 106 | * |
miruga27 | 0:7fb6877b5d7c | 107 | * If the function runs out of memory, it will return NULL. |
miruga27 | 0:7fb6877b5d7c | 108 | * |
miruga27 | 0:7fb6877b5d7c | 109 | * \param flags The \c flags are obsolete and should be set to 0. |
miruga27 | 0:7fb6877b5d7c | 110 | * \param width The width in pixels of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 111 | * \param height The height in pixels of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 112 | * \param depth The depth in bits of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 113 | * \param Rmask The red mask of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 114 | * \param Gmask The green mask of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 115 | * \param Bmask The blue mask of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 116 | * \param Amask The alpha mask of the surface to create. |
miruga27 | 0:7fb6877b5d7c | 117 | */ |
miruga27 | 0:7fb6877b5d7c | 118 | extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface |
miruga27 | 0:7fb6877b5d7c | 119 | (Uint32 flags, int width, int height, int depth, |
miruga27 | 0:7fb6877b5d7c | 120 | Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); |
miruga27 | 0:7fb6877b5d7c | 121 | extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, |
miruga27 | 0:7fb6877b5d7c | 122 | int width, |
miruga27 | 0:7fb6877b5d7c | 123 | int height, |
miruga27 | 0:7fb6877b5d7c | 124 | int depth, |
miruga27 | 0:7fb6877b5d7c | 125 | int pitch, |
miruga27 | 0:7fb6877b5d7c | 126 | Uint32 Rmask, |
miruga27 | 0:7fb6877b5d7c | 127 | Uint32 Gmask, |
miruga27 | 0:7fb6877b5d7c | 128 | Uint32 Bmask, |
miruga27 | 0:7fb6877b5d7c | 129 | Uint32 Amask); |
miruga27 | 0:7fb6877b5d7c | 130 | extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); |
miruga27 | 0:7fb6877b5d7c | 131 | |
miruga27 | 0:7fb6877b5d7c | 132 | /** |
miruga27 | 0:7fb6877b5d7c | 133 | * \brief Set the palette used by a surface. |
miruga27 | 0:7fb6877b5d7c | 134 | * |
miruga27 | 0:7fb6877b5d7c | 135 | * \return 0, or -1 if the surface format doesn't use a palette. |
miruga27 | 0:7fb6877b5d7c | 136 | * |
miruga27 | 0:7fb6877b5d7c | 137 | * \note A single palette can be shared with many surfaces. |
miruga27 | 0:7fb6877b5d7c | 138 | */ |
miruga27 | 0:7fb6877b5d7c | 139 | extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 140 | SDL_Palette * palette); |
miruga27 | 0:7fb6877b5d7c | 141 | |
miruga27 | 0:7fb6877b5d7c | 142 | /** |
miruga27 | 0:7fb6877b5d7c | 143 | * \brief Sets up a surface for directly accessing the pixels. |
miruga27 | 0:7fb6877b5d7c | 144 | * |
miruga27 | 0:7fb6877b5d7c | 145 | * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write |
miruga27 | 0:7fb6877b5d7c | 146 | * to and read from \c surface->pixels, using the pixel format stored in |
miruga27 | 0:7fb6877b5d7c | 147 | * \c surface->format. Once you are done accessing the surface, you should |
miruga27 | 0:7fb6877b5d7c | 148 | * use SDL_UnlockSurface() to release it. |
miruga27 | 0:7fb6877b5d7c | 149 | * |
miruga27 | 0:7fb6877b5d7c | 150 | * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates |
miruga27 | 0:7fb6877b5d7c | 151 | * to 0, then you can read and write to the surface at any time, and the |
miruga27 | 0:7fb6877b5d7c | 152 | * pixel format of the surface will not change. |
miruga27 | 0:7fb6877b5d7c | 153 | * |
miruga27 | 0:7fb6877b5d7c | 154 | * No operating system or library calls should be made between lock/unlock |
miruga27 | 0:7fb6877b5d7c | 155 | * pairs, as critical system locks may be held during this time. |
miruga27 | 0:7fb6877b5d7c | 156 | * |
miruga27 | 0:7fb6877b5d7c | 157 | * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. |
miruga27 | 0:7fb6877b5d7c | 158 | * |
miruga27 | 0:7fb6877b5d7c | 159 | * \sa SDL_UnlockSurface() |
miruga27 | 0:7fb6877b5d7c | 160 | */ |
miruga27 | 0:7fb6877b5d7c | 161 | extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); |
miruga27 | 0:7fb6877b5d7c | 162 | /** \sa SDL_LockSurface() */ |
miruga27 | 0:7fb6877b5d7c | 163 | extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); |
miruga27 | 0:7fb6877b5d7c | 164 | |
miruga27 | 0:7fb6877b5d7c | 165 | /** |
miruga27 | 0:7fb6877b5d7c | 166 | * Load a surface from a seekable SDL data stream (memory or file). |
miruga27 | 0:7fb6877b5d7c | 167 | * |
miruga27 | 0:7fb6877b5d7c | 168 | * If \c freesrc is non-zero, the stream will be closed after being read. |
miruga27 | 0:7fb6877b5d7c | 169 | * |
miruga27 | 0:7fb6877b5d7c | 170 | * The new surface should be freed with SDL_FreeSurface(). |
miruga27 | 0:7fb6877b5d7c | 171 | * |
miruga27 | 0:7fb6877b5d7c | 172 | * \return the new surface, or NULL if there was an error. |
miruga27 | 0:7fb6877b5d7c | 173 | */ |
miruga27 | 0:7fb6877b5d7c | 174 | extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, |
miruga27 | 0:7fb6877b5d7c | 175 | int freesrc); |
miruga27 | 0:7fb6877b5d7c | 176 | |
miruga27 | 0:7fb6877b5d7c | 177 | /** |
miruga27 | 0:7fb6877b5d7c | 178 | * Load a surface from a file. |
miruga27 | 0:7fb6877b5d7c | 179 | * |
miruga27 | 0:7fb6877b5d7c | 180 | * Convenience macro. |
miruga27 | 0:7fb6877b5d7c | 181 | */ |
miruga27 | 0:7fb6877b5d7c | 182 | #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) |
miruga27 | 0:7fb6877b5d7c | 183 | |
miruga27 | 0:7fb6877b5d7c | 184 | /** |
miruga27 | 0:7fb6877b5d7c | 185 | * Save a surface to a seekable SDL data stream (memory or file). |
miruga27 | 0:7fb6877b5d7c | 186 | * |
miruga27 | 0:7fb6877b5d7c | 187 | * If \c freedst is non-zero, the stream will be closed after being written. |
miruga27 | 0:7fb6877b5d7c | 188 | * |
miruga27 | 0:7fb6877b5d7c | 189 | * \return 0 if successful or -1 if there was an error. |
miruga27 | 0:7fb6877b5d7c | 190 | */ |
miruga27 | 0:7fb6877b5d7c | 191 | extern DECLSPEC int SDLCALL SDL_SaveBMP_RW |
miruga27 | 0:7fb6877b5d7c | 192 | (SDL_Surface * surface, SDL_RWops * dst, int freedst); |
miruga27 | 0:7fb6877b5d7c | 193 | |
miruga27 | 0:7fb6877b5d7c | 194 | /** |
miruga27 | 0:7fb6877b5d7c | 195 | * Save a surface to a file. |
miruga27 | 0:7fb6877b5d7c | 196 | * |
miruga27 | 0:7fb6877b5d7c | 197 | * Convenience macro. |
miruga27 | 0:7fb6877b5d7c | 198 | */ |
miruga27 | 0:7fb6877b5d7c | 199 | #define SDL_SaveBMP(surface, file) \ |
miruga27 | 0:7fb6877b5d7c | 200 | SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) |
miruga27 | 0:7fb6877b5d7c | 201 | |
miruga27 | 0:7fb6877b5d7c | 202 | /** |
miruga27 | 0:7fb6877b5d7c | 203 | * \brief Sets the RLE acceleration hint for a surface. |
miruga27 | 0:7fb6877b5d7c | 204 | * |
miruga27 | 0:7fb6877b5d7c | 205 | * \return 0 on success, or -1 if the surface is not valid |
miruga27 | 0:7fb6877b5d7c | 206 | * |
miruga27 | 0:7fb6877b5d7c | 207 | * \note If RLE is enabled, colorkey and alpha blending blits are much faster, |
miruga27 | 0:7fb6877b5d7c | 208 | * but the surface must be locked before directly accessing the pixels. |
miruga27 | 0:7fb6877b5d7c | 209 | */ |
miruga27 | 0:7fb6877b5d7c | 210 | extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 211 | int flag); |
miruga27 | 0:7fb6877b5d7c | 212 | |
miruga27 | 0:7fb6877b5d7c | 213 | /** |
miruga27 | 0:7fb6877b5d7c | 214 | * \brief Sets the color key (transparent pixel) in a blittable surface. |
miruga27 | 0:7fb6877b5d7c | 215 | * |
miruga27 | 0:7fb6877b5d7c | 216 | * \param surface The surface to update |
miruga27 | 0:7fb6877b5d7c | 217 | * \param flag Non-zero to enable colorkey and 0 to disable colorkey |
miruga27 | 0:7fb6877b5d7c | 218 | * \param key The transparent pixel in the native surface format |
miruga27 | 0:7fb6877b5d7c | 219 | * |
miruga27 | 0:7fb6877b5d7c | 220 | * \return 0 on success, or -1 if the surface is not valid |
miruga27 | 0:7fb6877b5d7c | 221 | * |
miruga27 | 0:7fb6877b5d7c | 222 | * You can pass SDL_RLEACCEL to enable RLE accelerated blits. |
miruga27 | 0:7fb6877b5d7c | 223 | */ |
miruga27 | 0:7fb6877b5d7c | 224 | extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 225 | int flag, Uint32 key); |
miruga27 | 0:7fb6877b5d7c | 226 | |
miruga27 | 0:7fb6877b5d7c | 227 | /** |
miruga27 | 0:7fb6877b5d7c | 228 | * \brief Gets the color key (transparent pixel) in a blittable surface. |
miruga27 | 0:7fb6877b5d7c | 229 | * |
miruga27 | 0:7fb6877b5d7c | 230 | * \param surface The surface to update |
miruga27 | 0:7fb6877b5d7c | 231 | * \param key A pointer filled in with the transparent pixel in the native |
miruga27 | 0:7fb6877b5d7c | 232 | * surface format |
miruga27 | 0:7fb6877b5d7c | 233 | * |
miruga27 | 0:7fb6877b5d7c | 234 | * \return 0 on success, or -1 if the surface is not valid or colorkey is not |
miruga27 | 0:7fb6877b5d7c | 235 | * enabled. |
miruga27 | 0:7fb6877b5d7c | 236 | */ |
miruga27 | 0:7fb6877b5d7c | 237 | extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 238 | Uint32 * key); |
miruga27 | 0:7fb6877b5d7c | 239 | |
miruga27 | 0:7fb6877b5d7c | 240 | /** |
miruga27 | 0:7fb6877b5d7c | 241 | * \brief Set an additional color value used in blit operations. |
miruga27 | 0:7fb6877b5d7c | 242 | * |
miruga27 | 0:7fb6877b5d7c | 243 | * \param surface The surface to update. |
miruga27 | 0:7fb6877b5d7c | 244 | * \param r The red color value multiplied into blit operations. |
miruga27 | 0:7fb6877b5d7c | 245 | * \param g The green color value multiplied into blit operations. |
miruga27 | 0:7fb6877b5d7c | 246 | * \param b The blue color value multiplied into blit operations. |
miruga27 | 0:7fb6877b5d7c | 247 | * |
miruga27 | 0:7fb6877b5d7c | 248 | * \return 0 on success, or -1 if the surface is not valid. |
miruga27 | 0:7fb6877b5d7c | 249 | * |
miruga27 | 0:7fb6877b5d7c | 250 | * \sa SDL_GetSurfaceColorMod() |
miruga27 | 0:7fb6877b5d7c | 251 | */ |
miruga27 | 0:7fb6877b5d7c | 252 | extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 253 | Uint8 r, Uint8 g, Uint8 b); |
miruga27 | 0:7fb6877b5d7c | 254 | |
miruga27 | 0:7fb6877b5d7c | 255 | |
miruga27 | 0:7fb6877b5d7c | 256 | /** |
miruga27 | 0:7fb6877b5d7c | 257 | * \brief Get the additional color value used in blit operations. |
miruga27 | 0:7fb6877b5d7c | 258 | * |
miruga27 | 0:7fb6877b5d7c | 259 | * \param surface The surface to query. |
miruga27 | 0:7fb6877b5d7c | 260 | * \param r A pointer filled in with the current red color value. |
miruga27 | 0:7fb6877b5d7c | 261 | * \param g A pointer filled in with the current green color value. |
miruga27 | 0:7fb6877b5d7c | 262 | * \param b A pointer filled in with the current blue color value. |
miruga27 | 0:7fb6877b5d7c | 263 | * |
miruga27 | 0:7fb6877b5d7c | 264 | * \return 0 on success, or -1 if the surface is not valid. |
miruga27 | 0:7fb6877b5d7c | 265 | * |
miruga27 | 0:7fb6877b5d7c | 266 | * \sa SDL_SetSurfaceColorMod() |
miruga27 | 0:7fb6877b5d7c | 267 | */ |
miruga27 | 0:7fb6877b5d7c | 268 | extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 269 | Uint8 * r, Uint8 * g, |
miruga27 | 0:7fb6877b5d7c | 270 | Uint8 * b); |
miruga27 | 0:7fb6877b5d7c | 271 | |
miruga27 | 0:7fb6877b5d7c | 272 | /** |
miruga27 | 0:7fb6877b5d7c | 273 | * \brief Set an additional alpha value used in blit operations. |
miruga27 | 0:7fb6877b5d7c | 274 | * |
miruga27 | 0:7fb6877b5d7c | 275 | * \param surface The surface to update. |
miruga27 | 0:7fb6877b5d7c | 276 | * \param alpha The alpha value multiplied into blit operations. |
miruga27 | 0:7fb6877b5d7c | 277 | * |
miruga27 | 0:7fb6877b5d7c | 278 | * \return 0 on success, or -1 if the surface is not valid. |
miruga27 | 0:7fb6877b5d7c | 279 | * |
miruga27 | 0:7fb6877b5d7c | 280 | * \sa SDL_GetSurfaceAlphaMod() |
miruga27 | 0:7fb6877b5d7c | 281 | */ |
miruga27 | 0:7fb6877b5d7c | 282 | extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 283 | Uint8 alpha); |
miruga27 | 0:7fb6877b5d7c | 284 | |
miruga27 | 0:7fb6877b5d7c | 285 | /** |
miruga27 | 0:7fb6877b5d7c | 286 | * \brief Get the additional alpha value used in blit operations. |
miruga27 | 0:7fb6877b5d7c | 287 | * |
miruga27 | 0:7fb6877b5d7c | 288 | * \param surface The surface to query. |
miruga27 | 0:7fb6877b5d7c | 289 | * \param alpha A pointer filled in with the current alpha value. |
miruga27 | 0:7fb6877b5d7c | 290 | * |
miruga27 | 0:7fb6877b5d7c | 291 | * \return 0 on success, or -1 if the surface is not valid. |
miruga27 | 0:7fb6877b5d7c | 292 | * |
miruga27 | 0:7fb6877b5d7c | 293 | * \sa SDL_SetSurfaceAlphaMod() |
miruga27 | 0:7fb6877b5d7c | 294 | */ |
miruga27 | 0:7fb6877b5d7c | 295 | extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 296 | Uint8 * alpha); |
miruga27 | 0:7fb6877b5d7c | 297 | |
miruga27 | 0:7fb6877b5d7c | 298 | /** |
miruga27 | 0:7fb6877b5d7c | 299 | * \brief Set the blend mode used for blit operations. |
miruga27 | 0:7fb6877b5d7c | 300 | * |
miruga27 | 0:7fb6877b5d7c | 301 | * \param surface The surface to update. |
miruga27 | 0:7fb6877b5d7c | 302 | * \param blendMode ::SDL_BlendMode to use for blit blending. |
miruga27 | 0:7fb6877b5d7c | 303 | * |
miruga27 | 0:7fb6877b5d7c | 304 | * \return 0 on success, or -1 if the parameters are not valid. |
miruga27 | 0:7fb6877b5d7c | 305 | * |
miruga27 | 0:7fb6877b5d7c | 306 | * \sa SDL_GetSurfaceBlendMode() |
miruga27 | 0:7fb6877b5d7c | 307 | */ |
miruga27 | 0:7fb6877b5d7c | 308 | extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 309 | SDL_BlendMode blendMode); |
miruga27 | 0:7fb6877b5d7c | 310 | |
miruga27 | 0:7fb6877b5d7c | 311 | /** |
miruga27 | 0:7fb6877b5d7c | 312 | * \brief Get the blend mode used for blit operations. |
miruga27 | 0:7fb6877b5d7c | 313 | * |
miruga27 | 0:7fb6877b5d7c | 314 | * \param surface The surface to query. |
miruga27 | 0:7fb6877b5d7c | 315 | * \param blendMode A pointer filled in with the current blend mode. |
miruga27 | 0:7fb6877b5d7c | 316 | * |
miruga27 | 0:7fb6877b5d7c | 317 | * \return 0 on success, or -1 if the surface is not valid. |
miruga27 | 0:7fb6877b5d7c | 318 | * |
miruga27 | 0:7fb6877b5d7c | 319 | * \sa SDL_SetSurfaceBlendMode() |
miruga27 | 0:7fb6877b5d7c | 320 | */ |
miruga27 | 0:7fb6877b5d7c | 321 | extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 322 | SDL_BlendMode *blendMode); |
miruga27 | 0:7fb6877b5d7c | 323 | |
miruga27 | 0:7fb6877b5d7c | 324 | /** |
miruga27 | 0:7fb6877b5d7c | 325 | * Sets the clipping rectangle for the destination surface in a blit. |
miruga27 | 0:7fb6877b5d7c | 326 | * |
miruga27 | 0:7fb6877b5d7c | 327 | * If the clip rectangle is NULL, clipping will be disabled. |
miruga27 | 0:7fb6877b5d7c | 328 | * |
miruga27 | 0:7fb6877b5d7c | 329 | * If the clip rectangle doesn't intersect the surface, the function will |
miruga27 | 0:7fb6877b5d7c | 330 | * return SDL_FALSE and blits will be completely clipped. Otherwise the |
miruga27 | 0:7fb6877b5d7c | 331 | * function returns SDL_TRUE and blits to the surface will be clipped to |
miruga27 | 0:7fb6877b5d7c | 332 | * the intersection of the surface area and the clipping rectangle. |
miruga27 | 0:7fb6877b5d7c | 333 | * |
miruga27 | 0:7fb6877b5d7c | 334 | * Note that blits are automatically clipped to the edges of the source |
miruga27 | 0:7fb6877b5d7c | 335 | * and destination surfaces. |
miruga27 | 0:7fb6877b5d7c | 336 | */ |
miruga27 | 0:7fb6877b5d7c | 337 | extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 338 | const SDL_Rect * rect); |
miruga27 | 0:7fb6877b5d7c | 339 | |
miruga27 | 0:7fb6877b5d7c | 340 | /** |
miruga27 | 0:7fb6877b5d7c | 341 | * Gets the clipping rectangle for the destination surface in a blit. |
miruga27 | 0:7fb6877b5d7c | 342 | * |
miruga27 | 0:7fb6877b5d7c | 343 | * \c rect must be a pointer to a valid rectangle which will be filled |
miruga27 | 0:7fb6877b5d7c | 344 | * with the correct values. |
miruga27 | 0:7fb6877b5d7c | 345 | */ |
miruga27 | 0:7fb6877b5d7c | 346 | extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, |
miruga27 | 0:7fb6877b5d7c | 347 | SDL_Rect * rect); |
miruga27 | 0:7fb6877b5d7c | 348 | |
miruga27 | 0:7fb6877b5d7c | 349 | /** |
miruga27 | 0:7fb6877b5d7c | 350 | * Creates a new surface of the specified format, and then copies and maps |
miruga27 | 0:7fb6877b5d7c | 351 | * the given surface to it so the blit of the converted surface will be as |
miruga27 | 0:7fb6877b5d7c | 352 | * fast as possible. If this function fails, it returns NULL. |
miruga27 | 0:7fb6877b5d7c | 353 | * |
miruga27 | 0:7fb6877b5d7c | 354 | * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those |
miruga27 | 0:7fb6877b5d7c | 355 | * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and |
miruga27 | 0:7fb6877b5d7c | 356 | * SDL will try to RLE accelerate colorkey and alpha blits in the resulting |
miruga27 | 0:7fb6877b5d7c | 357 | * surface. |
miruga27 | 0:7fb6877b5d7c | 358 | */ |
miruga27 | 0:7fb6877b5d7c | 359 | extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface |
miruga27 | 0:7fb6877b5d7c | 360 | (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); |
miruga27 | 0:7fb6877b5d7c | 361 | extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat |
miruga27 | 0:7fb6877b5d7c | 362 | (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); |
miruga27 | 0:7fb6877b5d7c | 363 | |
miruga27 | 0:7fb6877b5d7c | 364 | /** |
miruga27 | 0:7fb6877b5d7c | 365 | * \brief Copy a block of pixels of one format to another format |
miruga27 | 0:7fb6877b5d7c | 366 | * |
miruga27 | 0:7fb6877b5d7c | 367 | * \return 0 on success, or -1 if there was an error |
miruga27 | 0:7fb6877b5d7c | 368 | */ |
miruga27 | 0:7fb6877b5d7c | 369 | extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, |
miruga27 | 0:7fb6877b5d7c | 370 | Uint32 src_format, |
miruga27 | 0:7fb6877b5d7c | 371 | const void * src, int src_pitch, |
miruga27 | 0:7fb6877b5d7c | 372 | Uint32 dst_format, |
miruga27 | 0:7fb6877b5d7c | 373 | void * dst, int dst_pitch); |
miruga27 | 0:7fb6877b5d7c | 374 | |
miruga27 | 0:7fb6877b5d7c | 375 | /** |
miruga27 | 0:7fb6877b5d7c | 376 | * Performs a fast fill of the given rectangle with \c color. |
miruga27 | 0:7fb6877b5d7c | 377 | * |
miruga27 | 0:7fb6877b5d7c | 378 | * If \c rect is NULL, the whole surface will be filled with \c color. |
miruga27 | 0:7fb6877b5d7c | 379 | * |
miruga27 | 0:7fb6877b5d7c | 380 | * The color should be a pixel of the format used by the surface, and |
miruga27 | 0:7fb6877b5d7c | 381 | * can be generated by the SDL_MapRGB() function. |
miruga27 | 0:7fb6877b5d7c | 382 | * |
miruga27 | 0:7fb6877b5d7c | 383 | * \return 0 on success, or -1 on error. |
miruga27 | 0:7fb6877b5d7c | 384 | */ |
miruga27 | 0:7fb6877b5d7c | 385 | extern DECLSPEC int SDLCALL SDL_FillRect |
miruga27 | 0:7fb6877b5d7c | 386 | (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); |
miruga27 | 0:7fb6877b5d7c | 387 | extern DECLSPEC int SDLCALL SDL_FillRects |
miruga27 | 0:7fb6877b5d7c | 388 | (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); |
miruga27 | 0:7fb6877b5d7c | 389 | |
miruga27 | 0:7fb6877b5d7c | 390 | /** |
miruga27 | 0:7fb6877b5d7c | 391 | * Performs a fast blit from the source surface to the destination surface. |
miruga27 | 0:7fb6877b5d7c | 392 | * |
miruga27 | 0:7fb6877b5d7c | 393 | * This assumes that the source and destination rectangles are |
miruga27 | 0:7fb6877b5d7c | 394 | * the same size. If either \c srcrect or \c dstrect are NULL, the entire |
miruga27 | 0:7fb6877b5d7c | 395 | * surface (\c src or \c dst) is copied. The final blit rectangles are saved |
miruga27 | 0:7fb6877b5d7c | 396 | * in \c srcrect and \c dstrect after all clipping is performed. |
miruga27 | 0:7fb6877b5d7c | 397 | * |
miruga27 | 0:7fb6877b5d7c | 398 | * \return If the blit is successful, it returns 0, otherwise it returns -1. |
miruga27 | 0:7fb6877b5d7c | 399 | * |
miruga27 | 0:7fb6877b5d7c | 400 | * The blit function should not be called on a locked surface. |
miruga27 | 0:7fb6877b5d7c | 401 | * |
miruga27 | 0:7fb6877b5d7c | 402 | * The blit semantics for surfaces with and without blending and colorkey |
miruga27 | 0:7fb6877b5d7c | 403 | * are defined as follows: |
miruga27 | 0:7fb6877b5d7c | 404 | * \verbatim |
miruga27 | 0:7fb6877b5d7c | 405 | RGBA->RGB: |
miruga27 | 0:7fb6877b5d7c | 406 | Source surface blend mode set to SDL_BLENDMODE_BLEND: |
miruga27 | 0:7fb6877b5d7c | 407 | alpha-blend (using the source alpha-channel and per-surface alpha) |
miruga27 | 0:7fb6877b5d7c | 408 | SDL_SRCCOLORKEY ignored. |
miruga27 | 0:7fb6877b5d7c | 409 | Source surface blend mode set to SDL_BLENDMODE_NONE: |
miruga27 | 0:7fb6877b5d7c | 410 | copy RGB. |
miruga27 | 0:7fb6877b5d7c | 411 | if SDL_SRCCOLORKEY set, only copy the pixels matching the |
miruga27 | 0:7fb6877b5d7c | 412 | RGB values of the source color key, ignoring alpha in the |
miruga27 | 0:7fb6877b5d7c | 413 | comparison. |
miruga27 | 0:7fb6877b5d7c | 414 | |
miruga27 | 0:7fb6877b5d7c | 415 | RGB->RGBA: |
miruga27 | 0:7fb6877b5d7c | 416 | Source surface blend mode set to SDL_BLENDMODE_BLEND: |
miruga27 | 0:7fb6877b5d7c | 417 | alpha-blend (using the source per-surface alpha) |
miruga27 | 0:7fb6877b5d7c | 418 | Source surface blend mode set to SDL_BLENDMODE_NONE: |
miruga27 | 0:7fb6877b5d7c | 419 | copy RGB, set destination alpha to source per-surface alpha value. |
miruga27 | 0:7fb6877b5d7c | 420 | both: |
miruga27 | 0:7fb6877b5d7c | 421 | if SDL_SRCCOLORKEY set, only copy the pixels matching the |
miruga27 | 0:7fb6877b5d7c | 422 | source color key. |
miruga27 | 0:7fb6877b5d7c | 423 | |
miruga27 | 0:7fb6877b5d7c | 424 | RGBA->RGBA: |
miruga27 | 0:7fb6877b5d7c | 425 | Source surface blend mode set to SDL_BLENDMODE_BLEND: |
miruga27 | 0:7fb6877b5d7c | 426 | alpha-blend (using the source alpha-channel and per-surface alpha) |
miruga27 | 0:7fb6877b5d7c | 427 | SDL_SRCCOLORKEY ignored. |
miruga27 | 0:7fb6877b5d7c | 428 | Source surface blend mode set to SDL_BLENDMODE_NONE: |
miruga27 | 0:7fb6877b5d7c | 429 | copy all of RGBA to the destination. |
miruga27 | 0:7fb6877b5d7c | 430 | if SDL_SRCCOLORKEY set, only copy the pixels matching the |
miruga27 | 0:7fb6877b5d7c | 431 | RGB values of the source color key, ignoring alpha in the |
miruga27 | 0:7fb6877b5d7c | 432 | comparison. |
miruga27 | 0:7fb6877b5d7c | 433 | |
miruga27 | 0:7fb6877b5d7c | 434 | RGB->RGB: |
miruga27 | 0:7fb6877b5d7c | 435 | Source surface blend mode set to SDL_BLENDMODE_BLEND: |
miruga27 | 0:7fb6877b5d7c | 436 | alpha-blend (using the source per-surface alpha) |
miruga27 | 0:7fb6877b5d7c | 437 | Source surface blend mode set to SDL_BLENDMODE_NONE: |
miruga27 | 0:7fb6877b5d7c | 438 | copy RGB. |
miruga27 | 0:7fb6877b5d7c | 439 | both: |
miruga27 | 0:7fb6877b5d7c | 440 | if SDL_SRCCOLORKEY set, only copy the pixels matching the |
miruga27 | 0:7fb6877b5d7c | 441 | source color key. |
miruga27 | 0:7fb6877b5d7c | 442 | \endverbatim |
miruga27 | 0:7fb6877b5d7c | 443 | * |
miruga27 | 0:7fb6877b5d7c | 444 | * You should call SDL_BlitSurface() unless you know exactly how SDL |
miruga27 | 0:7fb6877b5d7c | 445 | * blitting works internally and how to use the other blit functions. |
miruga27 | 0:7fb6877b5d7c | 446 | */ |
miruga27 | 0:7fb6877b5d7c | 447 | #define SDL_BlitSurface SDL_UpperBlit |
miruga27 | 0:7fb6877b5d7c | 448 | |
miruga27 | 0:7fb6877b5d7c | 449 | /** |
miruga27 | 0:7fb6877b5d7c | 450 | * This is the public blit function, SDL_BlitSurface(), and it performs |
miruga27 | 0:7fb6877b5d7c | 451 | * rectangle validation and clipping before passing it to SDL_LowerBlit() |
miruga27 | 0:7fb6877b5d7c | 452 | */ |
miruga27 | 0:7fb6877b5d7c | 453 | extern DECLSPEC int SDLCALL SDL_UpperBlit |
miruga27 | 0:7fb6877b5d7c | 454 | (SDL_Surface * src, const SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 455 | SDL_Surface * dst, SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 456 | |
miruga27 | 0:7fb6877b5d7c | 457 | /** |
miruga27 | 0:7fb6877b5d7c | 458 | * This is a semi-private blit function and it performs low-level surface |
miruga27 | 0:7fb6877b5d7c | 459 | * blitting only. |
miruga27 | 0:7fb6877b5d7c | 460 | */ |
miruga27 | 0:7fb6877b5d7c | 461 | extern DECLSPEC int SDLCALL SDL_LowerBlit |
miruga27 | 0:7fb6877b5d7c | 462 | (SDL_Surface * src, SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 463 | SDL_Surface * dst, SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 464 | |
miruga27 | 0:7fb6877b5d7c | 465 | /** |
miruga27 | 0:7fb6877b5d7c | 466 | * \brief Perform a fast, low quality, stretch blit between two surfaces of the |
miruga27 | 0:7fb6877b5d7c | 467 | * same pixel format. |
miruga27 | 0:7fb6877b5d7c | 468 | * |
miruga27 | 0:7fb6877b5d7c | 469 | * \note This function uses a static buffer, and is not thread-safe. |
miruga27 | 0:7fb6877b5d7c | 470 | */ |
miruga27 | 0:7fb6877b5d7c | 471 | extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, |
miruga27 | 0:7fb6877b5d7c | 472 | const SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 473 | SDL_Surface * dst, |
miruga27 | 0:7fb6877b5d7c | 474 | const SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 475 | |
miruga27 | 0:7fb6877b5d7c | 476 | #define SDL_BlitScaled SDL_UpperBlitScaled |
miruga27 | 0:7fb6877b5d7c | 477 | |
miruga27 | 0:7fb6877b5d7c | 478 | /** |
miruga27 | 0:7fb6877b5d7c | 479 | * This is the public scaled blit function, SDL_BlitScaled(), and it performs |
miruga27 | 0:7fb6877b5d7c | 480 | * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() |
miruga27 | 0:7fb6877b5d7c | 481 | */ |
miruga27 | 0:7fb6877b5d7c | 482 | extern DECLSPEC int SDLCALL SDL_UpperBlitScaled |
miruga27 | 0:7fb6877b5d7c | 483 | (SDL_Surface * src, const SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 484 | SDL_Surface * dst, SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 485 | |
miruga27 | 0:7fb6877b5d7c | 486 | /** |
miruga27 | 0:7fb6877b5d7c | 487 | * This is a semi-private blit function and it performs low-level surface |
miruga27 | 0:7fb6877b5d7c | 488 | * scaled blitting only. |
miruga27 | 0:7fb6877b5d7c | 489 | */ |
miruga27 | 0:7fb6877b5d7c | 490 | extern DECLSPEC int SDLCALL SDL_LowerBlitScaled |
miruga27 | 0:7fb6877b5d7c | 491 | (SDL_Surface * src, SDL_Rect * srcrect, |
miruga27 | 0:7fb6877b5d7c | 492 | SDL_Surface * dst, SDL_Rect * dstrect); |
miruga27 | 0:7fb6877b5d7c | 493 | |
miruga27 | 0:7fb6877b5d7c | 494 | |
miruga27 | 0:7fb6877b5d7c | 495 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 496 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 497 | } |
miruga27 | 0:7fb6877b5d7c | 498 | #endif |
miruga27 | 0:7fb6877b5d7c | 499 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 500 | |
miruga27 | 0:7fb6877b5d7c | 501 | #endif /* _SDL_surface_h */ |
miruga27 | 0:7fb6877b5d7c | 502 | |
miruga27 | 0:7fb6877b5d7c | 503 | /* vi: set ts=4 sw=4 expandtab: */ |