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