include/SDL_surface.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 08 Dec 2008 00:27:32 +0000
changeset 2859 99210400e8b9
parent 2828 7e5ff6cd05bf
child 2888 32e8bbba1e94
permissions -rw-r--r--
Updated copyright date
slouken@2275
     1
/*
slouken@2275
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@2275
     4
slouken@2275
     5
    This library is free software; you can redistribute it and/or
slouken@2275
     6
    modify it under the terms of the GNU Lesser General Public
slouken@2275
     7
    License as published by the Free Software Foundation; either
slouken@2275
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@2275
     9
slouken@2275
    10
    This library is distributed in the hope that it will be useful,
slouken@2275
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2275
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2275
    13
    Lesser General Public License for more details.
slouken@2275
    14
slouken@2275
    15
    You should have received a copy of the GNU Lesser General Public
slouken@2275
    16
    License along with this library; if not, write to the Free Software
slouken@2275
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2275
    18
slouken@2275
    19
    Sam Lantinga
slouken@2275
    20
    slouken@libsdl.org
slouken@2275
    21
*/
slouken@2275
    22
slouken@2275
    23
/**
slouken@2275
    24
 * \file SDL_surface.h
slouken@2275
    25
 *
slouken@2275
    26
 * Header file for SDL_surface definition and management functions
slouken@2275
    27
 */
slouken@2275
    28
slouken@2275
    29
#ifndef _SDL_surface_h
slouken@2275
    30
#define _SDL_surface_h
slouken@2275
    31
slouken@2275
    32
#include "SDL_stdinc.h"
slouken@2275
    33
#include "SDL_pixels.h"
slouken@2275
    34
#include "SDL_rect.h"
slouken@2275
    35
#include "SDL_rwops.h"
slouken@2275
    36
slouken@2275
    37
#include "begin_code.h"
slouken@2275
    38
/* Set up for C function definitions, even when using C++ */
slouken@2275
    39
#ifdef __cplusplus
slouken@2275
    40
/* *INDENT-OFF* */
slouken@2275
    41
extern "C" {
slouken@2275
    42
/* *INDENT-ON* */
slouken@2275
    43
#endif
slouken@2275
    44
slouken@2275
    45
/* These are the currently supported flags for the SDL_surface */
slouken@2275
    46
/* Used internally (read-only) */
slouken@2275
    47
#define SDL_PREALLOC        0x00000001  /* Surface uses preallocated memory */
slouken@2275
    48
#define SDL_RLEACCEL        0x00000002  /* Surface is RLE encoded */
slouken@2275
    49
slouken@2275
    50
/* Evaluates to true if the surface needs to be locked before access */
slouken@2275
    51
#define SDL_MUSTLOCK(S)	(((S)->flags & SDL_RLEACCEL) != 0)
slouken@2275
    52
slouken@2275
    53
/**
slouken@2275
    54
 * \struct SDL_Surface
slouken@2275
    55
 *
slouken@2275
    56
 * \brief A collection of pixels used in software blitting
slouken@2275
    57
 *
slouken@2275
    58
 * \note  This structure should be treated as read-only, except for 'pixels',
slouken@2275
    59
 *        which, if not NULL, contains the raw pixel data for the surface.
slouken@2275
    60
 */
slouken@2275
    61
typedef struct SDL_Surface
slouken@2275
    62
{
slouken@2275
    63
    Uint32 flags;               /**< Read-only */
slouken@2275
    64
    SDL_PixelFormat *format;    /**< Read-only */
slouken@2275
    65
    int w, h;                   /**< Read-only */
slouken@2275
    66
    int pitch;                  /**< Read-only */
slouken@2275
    67
    void *pixels;               /**< Read-write */
slouken@2275
    68
slouken@2275
    69
    /* Application data associated with the surfade */
slouken@2275
    70
    void *userdata;             /**< Read-write */
slouken@2275
    71
slouken@2275
    72
    /* information needed for surfaces requiring locks */
slouken@2275
    73
    int locked;                 /**< Read-only */
slouken@2275
    74
    void *lock_data;            /**< Read-only */
slouken@2275
    75
slouken@2275
    76
    /* clipping information */
slouken@2275
    77
    SDL_Rect clip_rect;         /**< Read-only */
slouken@2275
    78
slouken@2275
    79
    /* info for fast blit mapping to other surfaces */
slouken@2275
    80
    struct SDL_BlitMap *map;    /**< Private */
slouken@2275
    81
slouken@2275
    82
    /* format version, bumped at every change to invalidate blit maps */
slouken@2275
    83
    unsigned int format_version;        /**< Private */
slouken@2275
    84
slouken@2275
    85
    /* Reference count -- used when freeing surface */
slouken@2275
    86
    int refcount;               /**< Read-mostly */
slouken@2275
    87
} SDL_Surface;
slouken@2275
    88
slouken@2275
    89
/**
slouken@2275
    90
 * \typedef SDL_blit
slouken@2275
    91
 *
slouken@2275
    92
 * \brief The type of function used for surface blitting functions
slouken@2275
    93
 */
slouken@2275
    94
typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
    95
                         struct SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
    96
slouken@2275
    97
/*
slouken@2275
    98
 * Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
slouken@2275
    99
 * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
slouken@2275
   100
 * If the depth is greater than 8 bits, the pixel format is set using the
slouken@2275
   101
 * flags '[RGB]mask'.
slouken@2275
   102
 * If the function runs out of memory, it will return NULL.
slouken@2275
   103
 *
slouken@2807
   104
 * The 'flags' are obsolete and should be set to 0.
slouken@2275
   105
 */
slouken@2275
   106
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
slouken@2275
   107
    (Uint32 flags, int width, int height, int depth,
slouken@2275
   108
     Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
slouken@2275
   109
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
slouken@2275
   110
                                                              int width,
slouken@2275
   111
                                                              int height,
slouken@2275
   112
                                                              int depth,
slouken@2275
   113
                                                              int pitch,
slouken@2275
   114
                                                              Uint32 Rmask,
slouken@2275
   115
                                                              Uint32 Gmask,
slouken@2275
   116
                                                              Uint32 Bmask,
slouken@2275
   117
                                                              Uint32 Amask);
slouken@2275
   118
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
slouken@2275
   119
slouken@2275
   120
/**
slouken@2275
   121
 * \fn int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
slouken@2275
   122
 *
slouken@2275
   123
 * \brief Set the palette used by a surface.
slouken@2275
   124
 *
slouken@2275
   125
 * \return 0, or -1 if the surface format doesn't use a palette.
slouken@2275
   126
 *
slouken@2275
   127
 * \note A single palette can be shared with many surfaces.
slouken@2275
   128
 */
slouken@2275
   129
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
slouken@2275
   130
                                                  SDL_Palette * palette);
slouken@2275
   131
slouken@2275
   132
/*
slouken@2275
   133
 * SDL_LockSurface() sets up a surface for directly accessing the pixels.
slouken@2275
   134
 * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
slouken@2275
   135
 * to and read from 'surface->pixels', using the pixel format stored in 
slouken@2275
   136
 * 'surface->format'.  Once you are done accessing the surface, you should 
slouken@2275
   137
 * use SDL_UnlockSurface() to release it.
slouken@2275
   138
 *
slouken@2275
   139
 * Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
slouken@2275
   140
 * to 0, then you can read and write to the surface at any time, and the
slouken@2275
   141
 * pixel format of the surface will not change.
slouken@2275
   142
 * 
slouken@2275
   143
 * No operating system or library calls should be made between lock/unlock
slouken@2275
   144
 * pairs, as critical system locks may be held during this time.
slouken@2275
   145
 *
slouken@2275
   146
 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
slouken@2275
   147
 */
slouken@2275
   148
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
slouken@2275
   149
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
slouken@2275
   150
slouken@2275
   151
/*
slouken@2275
   152
 * Load a surface from a seekable SDL data source (memory or file.)
slouken@2275
   153
 * If 'freesrc' is non-zero, the source will be closed after being read.
slouken@2275
   154
 * Returns the new surface, or NULL if there was an error.
slouken@2275
   155
 * The new surface should be freed with SDL_FreeSurface().
slouken@2275
   156
 */
slouken@2275
   157
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
slouken@2275
   158
                                                    int freesrc);
slouken@2275
   159
slouken@2275
   160
/* Convenience macro -- load a surface from a file */
slouken@2275
   161
#define SDL_LoadBMP(file)	SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
slouken@2275
   162
slouken@2275
   163
/*
slouken@2275
   164
 * Save a surface to a seekable SDL data source (memory or file.)
slouken@2275
   165
 * If 'freedst' is non-zero, the source will be closed after being written.
slouken@2275
   166
 * Returns 0 if successful or -1 if there was an error.
slouken@2275
   167
 */
slouken@2275
   168
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
slouken@2275
   169
    (SDL_Surface * surface, SDL_RWops * dst, int freedst);
slouken@2275
   170
slouken@2275
   171
/* Convenience macro -- save a surface to a file */
slouken@2275
   172
#define SDL_SaveBMP(surface, file) \
slouken@2275
   173
		SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
slouken@2275
   174
slouken@2275
   175
/*
slouken@2275
   176
 * \fn int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
slouken@2275
   177
 *
slouken@2275
   178
 * \brief Sets the RLE acceleration hint for a surface.
slouken@2275
   179
 *
slouken@2275
   180
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   181
 *
slouken@2275
   182
 * \note If RLE is enabled, colorkey and alpha blending blits are much faster,
slouken@2275
   183
 *       but the surface must be locked before directly accessing the pixels.
slouken@2275
   184
 */
slouken@2275
   185
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
slouken@2275
   186
                                              int flag);
slouken@2275
   187
slouken@2275
   188
/*
slouken@2275
   189
 * \fn int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
slouken@2275
   190
 *
slouken@2275
   191
 * \brief Sets the color key (transparent pixel) in a blittable surface.
slouken@2275
   192
 *
slouken@2275
   193
 * \param surface The surface to update
slouken@2275
   194
 * \param flag Non-zero to enable colorkey and 0 to disable colorkey 
slouken@2275
   195
 * \param key The transparent pixel in the native surface format
slouken@2275
   196
 *
slouken@2275
   197
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   198
 */
slouken@2275
   199
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
slouken@2275
   200
                                            Uint32 flag, Uint32 key);
slouken@2275
   201
slouken@2275
   202
/**
slouken@2275
   203
 * \fn int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
slouken@2275
   204
 *
slouken@2275
   205
 * \brief Set an additional color value used in blit operations
slouken@2275
   206
 *
slouken@2275
   207
 * \param surface The surface to update
slouken@2275
   208
 * \param r The red source color value multiplied into blit operations
slouken@2275
   209
 * \param g The green source color value multiplied into blit operations
slouken@2275
   210
 * \param b The blue source color value multiplied into blit operations
slouken@2275
   211
 *
slouken@2275
   212
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   213
 *
slouken@2275
   214
 * \sa SDL_GetSurfaceColorMod()
slouken@2275
   215
 */
slouken@2275
   216
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   217
                                                   Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   218
slouken@2275
   219
slouken@2275
   220
/**
slouken@2275
   221
 * \fn int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
slouken@2275
   222
 *
slouken@2275
   223
 * \brief Get the additional color value used in blit operations
slouken@2275
   224
 *
slouken@2275
   225
 * \param surface The surface to query
slouken@2275
   226
 * \param r A pointer filled in with the source red color value
slouken@2275
   227
 * \param g A pointer filled in with the source green color value
slouken@2275
   228
 * \param b A pointer filled in with the source blue color value
slouken@2275
   229
 *
slouken@2275
   230
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   231
 *
slouken@2275
   232
 * \sa SDL_SetSurfaceColorMod()
slouken@2275
   233
 */
slouken@2275
   234
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   235
                                                   Uint8 * r, Uint8 * g,
slouken@2275
   236
                                                   Uint8 * b);
slouken@2275
   237
slouken@2275
   238
/**
slouken@2275
   239
 * \fn int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
slouken@2275
   240
 *
slouken@2275
   241
 * \brief Set an additional alpha value used in blit operations
slouken@2275
   242
 *
slouken@2275
   243
 * \param surface The surface to update
slouken@2275
   244
 * \param alpha The source alpha value multiplied into blit operations.
slouken@2275
   245
 *
slouken@2275
   246
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   247
 *
slouken@2275
   248
 * \sa SDL_GetSurfaceAlphaMod()
slouken@2275
   249
 */
slouken@2275
   250
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   251
                                                   Uint8 alpha);
slouken@2275
   252
slouken@2275
   253
/**
slouken@2275
   254
 * \fn int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
slouken@2275
   255
 *
slouken@2275
   256
 * \brief Get the additional alpha value used in blit operations
slouken@2275
   257
 *
slouken@2275
   258
 * \param surface The surface to query
slouken@2275
   259
 * \param alpha A pointer filled in with the source alpha value
slouken@2275
   260
 *
slouken@2275
   261
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   262
 *
slouken@2275
   263
 * \sa SDL_SetSurfaceAlphaMod()
slouken@2275
   264
 */
slouken@2275
   265
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   266
                                                   Uint8 * alpha);
slouken@2275
   267
slouken@2275
   268
/**
slouken@2275
   269
 * \fn int SDL_SetSurfaceBlendMode(SDL_Surface *surface, int blendMode)
slouken@2275
   270
 *
slouken@2275
   271
 * \brief Set the blend mode used for blit operations
slouken@2275
   272
 *
slouken@2275
   273
 * \param surface The surface to update
slouken@2275
   274
 * \param blendMode SDL_TextureBlendMode to use for blit blending
slouken@2275
   275
 *
slouken@2275
   276
 * \return 0 on success, or -1 if the parameters are not valid
slouken@2275
   277
 *
slouken@2275
   278
 * \sa SDL_GetSurfaceBlendMode()
slouken@2275
   279
 */
slouken@2275
   280
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
slouken@2275
   281
                                                    int blendMode);
slouken@2275
   282
slouken@2275
   283
/**
slouken@2275
   284
 * \fn int SDL_GetSurfaceBlendMode(SDL_Surface *surface, int *blendMode)
slouken@2275
   285
 *
slouken@2275
   286
 * \brief Get the blend mode used for blit operations
slouken@2275
   287
 *
slouken@2275
   288
 * \param surface The surface to query
slouken@2275
   289
 * \param blendMode A pointer filled in with the current blend mode
slouken@2275
   290
 *
slouken@2275
   291
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   292
 *
slouken@2275
   293
 * \sa SDL_SetSurfaceBlendMode()
slouken@2275
   294
 */
slouken@2275
   295
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
slouken@2275
   296
                                                    int *blendMode);
slouken@2275
   297
slouken@2275
   298
/**
slouken@2275
   299
 * \fn int SDL_SetSurfaceScaleMode(SDL_Surface *surface, int scaleMode)
slouken@2275
   300
 *
slouken@2275
   301
 * \brief Set the scale mode used for blit operations
slouken@2275
   302
 *
slouken@2275
   303
 * \param surface The surface to update
slouken@2275
   304
 * \param scaleMode SDL_TextureScaleMode to use for blit scaling
slouken@2275
   305
 *
slouken@2275
   306
 * \return 0 on success, or -1 if the surface is not valid or the scale mode is not supported
slouken@2275
   307
 *
slouken@2275
   308
 * \note If the scale mode is not supported, the closest supported mode is chosen.  Currently only SDL_TEXTURESCALEMODE_FAST is supported on surfaces.
slouken@2275
   309
 *
slouken@2275
   310
 * \sa SDL_GetSurfaceScaleMode()
slouken@2275
   311
 */
slouken@2275
   312
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
slouken@2275
   313
                                                    int scaleMode);
slouken@2275
   314
slouken@2275
   315
/**
slouken@2275
   316
 * \fn int SDL_GetSurfaceScaleMode(SDL_Surface *surface, int *scaleMode)
slouken@2275
   317
 *
slouken@2275
   318
 * \brief Get the scale mode used for blit operations
slouken@2275
   319
 *
slouken@2275
   320
 * \param surface The surface to query
slouken@2275
   321
 * \param scaleMode A pointer filled in with the current scale mode
slouken@2275
   322
 *
slouken@2275
   323
 * \return 0 on success, or -1 if the surface is not valid
slouken@2275
   324
 *
slouken@2275
   325
 * \sa SDL_SetSurfaceScaleMode()
slouken@2275
   326
 */
slouken@2275
   327
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
slouken@2275
   328
                                                    int *scaleMode);
slouken@2275
   329
slouken@2275
   330
/*
slouken@2275
   331
 * Sets the clipping rectangle for the destination surface in a blit.
slouken@2275
   332
 *
slouken@2275
   333
 * If the clip rectangle is NULL, clipping will be disabled.
slouken@2275
   334
 * If the clip rectangle doesn't intersect the surface, the function will
slouken@2275
   335
 * return SDL_FALSE and blits will be completely clipped.  Otherwise the
slouken@2275
   336
 * function returns SDL_TRUE and blits to the surface will be clipped to
slouken@2275
   337
 * the intersection of the surface area and the clipping rectangle.
slouken@2275
   338
 *
slouken@2275
   339
 * Note that blits are automatically clipped to the edges of the source
slouken@2275
   340
 * and destination surfaces.
slouken@2275
   341
 */
slouken@2275
   342
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
slouken@2275
   343
                                                 const SDL_Rect * rect);
slouken@2275
   344
slouken@2275
   345
/*
slouken@2275
   346
 * Gets the clipping rectangle for the destination surface in a blit.
slouken@2275
   347
 * 'rect' must be a pointer to a valid rectangle which will be filled
slouken@2275
   348
 * with the correct values.
slouken@2275
   349
 */
slouken@2275
   350
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
slouken@2275
   351
                                             SDL_Rect * rect);
slouken@2275
   352
slouken@2275
   353
/*
slouken@2275
   354
 * Creates a new surface of the specified format, and then copies and maps 
slouken@2275
   355
 * the given surface to it so the blit of the converted surface will be as 
slouken@2275
   356
 * fast as possible.  If this function fails, it returns NULL.
slouken@2275
   357
 *
slouken@2275
   358
 * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those 
slouken@2275
   359
 * semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
slouken@2275
   360
 * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
slouken@2275
   361
 * surface.
slouken@2275
   362
 *
slouken@2275
   363
 * This function is used internally by SDL_DisplayFormat().
slouken@2275
   364
 */
slouken@2275
   365
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
slouken@2275
   366
    (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
slouken@2275
   367
slouken@2275
   368
/*
slouken@2275
   369
 * This function performs a fast fill of the given rectangle with 'color'
slouken@2275
   370
 * The given rectangle is clipped to the destination surface clip area
slouken@2275
   371
 * and the final fill rectangle is saved in the passed in pointer.
slouken@2275
   372
 * If 'dstrect' is NULL, the whole surface will be filled with 'color'
slouken@2275
   373
 * The color should be a pixel of the format used by the surface, and 
slouken@2275
   374
 * can be generated by the SDL_MapRGB() function.
slouken@2275
   375
 * This function returns 0 on success, or -1 on error.
slouken@2275
   376
 */
slouken@2275
   377
extern DECLSPEC int SDLCALL SDL_FillRect
slouken@2275
   378
    (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color);
slouken@2275
   379
slouken@2275
   380
/*
slouken@2275
   381
 * This performs a fast blit from the source surface to the destination
slouken@2275
   382
 * surface.  It assumes that the source and destination rectangles are
slouken@2275
   383
 * the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
slouken@2275
   384
 * surface (src or dst) is copied.  The final blit rectangles are saved
slouken@2275
   385
 * in 'srcrect' and 'dstrect' after all clipping is performed.
slouken@2275
   386
 * If the blit is successful, it returns 0, otherwise it returns -1.
slouken@2275
   387
 *
slouken@2275
   388
 * The blit function should not be called on a locked surface.
slouken@2275
   389
 *
slouken@2275
   390
 * The blit semantics for surfaces with and without alpha and colorkey
slouken@2275
   391
 * are defined as follows:
slouken@2275
   392
 *
slouken@2275
   393
 * RGBA->RGB:
slouken@2275
   394
 *     SDL_SRCALPHA set:
slouken@2275
   395
 * 	alpha-blend (using alpha-channel).
slouken@2275
   396
 * 	SDL_SRCCOLORKEY ignored.
slouken@2275
   397
 *     SDL_SRCALPHA not set:
slouken@2275
   398
 * 	copy RGB.
slouken@2275
   399
 * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
slouken@2275
   400
 * 	RGB values of the source colour key, ignoring alpha in the
slouken@2275
   401
 * 	comparison.
slouken@2275
   402
 * 
slouken@2275
   403
 * RGB->RGBA:
slouken@2275
   404
 *     SDL_SRCALPHA set:
slouken@2275
   405
 * 	alpha-blend (using the source per-surface alpha value);
slouken@2275
   406
 * 	set destination alpha to opaque.
slouken@2275
   407
 *     SDL_SRCALPHA not set:
slouken@2275
   408
 * 	copy RGB, set destination alpha to source per-surface alpha value.
slouken@2275
   409
 *     both:
slouken@2275
   410
 * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
slouken@2275
   411
 * 	source colour key.
slouken@2275
   412
 * 
slouken@2275
   413
 * RGBA->RGBA:
slouken@2275
   414
 *     SDL_SRCALPHA set:
slouken@2275
   415
 * 	alpha-blend (using the source alpha channel) the RGB values;
slouken@2275
   416
 * 	leave destination alpha untouched. [Note: is this correct?]
slouken@2275
   417
 * 	SDL_SRCCOLORKEY ignored.
slouken@2275
   418
 *     SDL_SRCALPHA not set:
slouken@2275
   419
 * 	copy all of RGBA to the destination.
slouken@2275
   420
 * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
slouken@2275
   421
 * 	RGB values of the source colour key, ignoring alpha in the
slouken@2275
   422
 * 	comparison.
slouken@2275
   423
 * 
slouken@2275
   424
 * RGB->RGB: 
slouken@2275
   425
 *     SDL_SRCALPHA set:
slouken@2275
   426
 * 	alpha-blend (using the source per-surface alpha value).
slouken@2275
   427
 *     SDL_SRCALPHA not set:
slouken@2275
   428
 * 	copy RGB.
slouken@2275
   429
 *     both:
slouken@2275
   430
 * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
slouken@2275
   431
 * 	source colour key.
slouken@2275
   432
 *
slouken@2275
   433
 * If either of the surfaces were in video memory, and the blit returns -2,
slouken@2275
   434
 * the video memory was lost, so it should be reloaded with artwork and 
slouken@2275
   435
 * re-blitted:
slouken@2275
   436
	while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
slouken@2275
   437
		while ( SDL_LockSurface(image) < 0 )
slouken@2275
   438
			Sleep(10);
slouken@2275
   439
		-- Write image pixels to image->pixels --
slouken@2275
   440
		SDL_UnlockSurface(image);
slouken@2275
   441
	}
slouken@2275
   442
 * This happens under DirectX 5.0 when the system switches away from your
slouken@2275
   443
 * fullscreen application.  The lock will also fail until you have access
slouken@2275
   444
 * to the video memory again.
slouken@2275
   445
 */
slouken@2275
   446
/* You should call SDL_BlitSurface() unless you know exactly how SDL
slouken@2275
   447
   blitting works internally and how to use the other blit functions.
slouken@2275
   448
*/
slouken@2275
   449
#define SDL_BlitSurface SDL_UpperBlit
slouken@2275
   450
slouken@2275
   451
/* This is the public blit function, SDL_BlitSurface(), and it performs
slouken@2275
   452
   rectangle validation and clipping before passing it to SDL_LowerBlit()
slouken@2275
   453
*/
slouken@2275
   454
extern DECLSPEC int SDLCALL SDL_UpperBlit
slouken@2275
   455
    (SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
   456
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
   457
/* This is a semi-private blit function and it performs low-level surface
slouken@2275
   458
   blitting only.
slouken@2275
   459
*/
slouken@2275
   460
extern DECLSPEC int SDLCALL SDL_LowerBlit
slouken@2275
   461
    (SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
   462
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
   463
slouken@2275
   464
/**
slouken@2828
   465
 * \fn int SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect)
slouken@2275
   466
 *
slouken@2275
   467
 * \brief Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
slouken@2275
   468
 *
slouken@2275
   469
 * \note This function uses a static buffer, and is not thread-safe.
slouken@2275
   470
 */
slouken@2275
   471
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
slouken@2828
   472
                                            const SDL_Rect * srcrect,
slouken@2275
   473
                                            SDL_Surface * dst,
slouken@2828
   474
                                            const SDL_Rect * dstrect);
slouken@2275
   475
slouken@2275
   476
/* Ends C function definitions when using C++ */
slouken@2275
   477
#ifdef __cplusplus
slouken@2275
   478
/* *INDENT-OFF* */
slouken@2275
   479
}
slouken@2275
   480
/* *INDENT-ON* */
slouken@2275
   481
#endif
slouken@2275
   482
#include "close_code.h"
slouken@2275
   483
slouken@2275
   484
#endif /* _SDL_surface_h */
slouken@2275
   485
slouken@2275
   486
/* vi: set ts=4 sw=4 expandtab: */