include/SDL_surface.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 04 Oct 2009 19:14:30 +0000
changeset 3341 710139a1692d
parent 3103 7be21a78777e
child 3407 d3baf5ac4e37
permissions -rw-r--r--
Fixed bug #826

Ken Bull 2009-10-04 09:51:30 PDT

2009/10/4 E. Wing <ewmailing@gmail.com>:
> Hi Kenneth,
> I noticed that SDL_SetColorKey and SDL_GetColorKey start with
> /*
> instead of
> /**
> in SDL_Surface.h in SDL 1.3.
>
> I haven't scrutinized the headers and I don't know if you had an
> automated process to add these, but I thought I would let you know in
> case there might be others that have the same problem.
>
> Thanks,
> Eric
>

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