include/SDL_surface.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 25 Oct 2018 12:54:42 -0700
changeset 12357 40f09c8c517b
parent 12204 5486557ca8d9
child 12503 806492103856
permissions -rw-r--r--
Added SDL_JoystickGetXInputUserIndex()
slouken@2275
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@2275
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2275
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2275
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2275
    20
*/
slouken@2275
    21
slouken@2275
    22
/**
slouken@3407
    23
 *  \file SDL_surface.h
slouken@7191
    24
 *
philipp@7278
    25
 *  Header file for ::SDL_Surface definition and management functions.
slouken@2275
    26
 */
slouken@2275
    27
slouken@10638
    28
#ifndef SDL_surface_h_
slouken@10638
    29
#define SDL_surface_h_
slouken@2275
    30
slouken@2275
    31
#include "SDL_stdinc.h"
slouken@2275
    32
#include "SDL_pixels.h"
slouken@2275
    33
#include "SDL_rect.h"
slouken@4929
    34
#include "SDL_blendmode.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
extern "C" {
slouken@2275
    41
#endif
slouken@2275
    42
slouken@3407
    43
/**
slouken@3407
    44
 *  \name Surface flags
slouken@7191
    45
 *
philipp@7278
    46
 *  These are the currently supported flags for the ::SDL_Surface.
slouken@7191
    47
 *
slouken@3407
    48
 *  \internal
slouken@3407
    49
 *  Used internally (read-only).
slouken@3341
    50
 */
gabomdq@7678
    51
/* @{ */
slouken@6257
    52
#define SDL_SWSURFACE       0           /**< Just here for compatibility */
slouken@3341
    53
#define SDL_PREALLOC        0x00000001  /**< Surface uses preallocated memory */
slouken@3341
    54
#define SDL_RLEACCEL        0x00000002  /**< Surface is RLE encoded */
slouken@5288
    55
#define SDL_DONTFREE        0x00000004  /**< Surface is referenced internally */
gabomdq@7678
    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@7191
    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@3708
    77
    /** Application data associated with the surface */
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
    /** Reference count -- used when freeing surface */
slouken@2275
    91
    int refcount;               /**< Read-mostly */
slouken@2275
    92
} SDL_Surface;
slouken@2275
    93
slouken@2275
    94
/**
slouken@3407
    95
 * \brief The type of function used for surface blitting functions.
slouken@2275
    96
 */
slouken@11284
    97
typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
slouken@11284
    98
                                 struct SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
    99
slouken@3341
   100
/**
slouken@11702
   101
 * \brief The formula used for converting between YUV and RGB
slouken@11702
   102
 */
slouken@11702
   103
typedef enum
slouken@11702
   104
{
slouken@11702
   105
    SDL_YUV_CONVERSION_JPEG,        /**< Full range JPEG */
slouken@11702
   106
    SDL_YUV_CONVERSION_BT601,       /**< BT.601 (the default) */
slouken@11702
   107
    SDL_YUV_CONVERSION_BT709,       /**< BT.709 */
slouken@11702
   108
    SDL_YUV_CONVERSION_AUTOMATIC    /**< BT.601 for SD content, BT.709 for HD content */
slouken@11702
   109
} SDL_YUV_CONVERSION_MODE;
slouken@11702
   110
slouken@11702
   111
/**
slouken@4424
   112
 *  Allocate and free an RGB surface.
slouken@7191
   113
 *
slouken@3407
   114
 *  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
slouken@3407
   115
 *  If the depth is greater than 8 bits, the pixel format is set using the
slouken@3407
   116
 *  flags '[RGB]mask'.
slouken@7191
   117
 *
slouken@3407
   118
 *  If the function runs out of memory, it will return NULL.
slouken@7191
   119
 *
slouken@3407
   120
 *  \param flags The \c flags are obsolete and should be set to 0.
philipp@7188
   121
 *  \param width The width in pixels of the surface to create.
philipp@7188
   122
 *  \param height The height in pixels of the surface to create.
philipp@7188
   123
 *  \param depth The depth in bits of the surface to create.
philipp@7188
   124
 *  \param Rmask The red mask of the surface to create.
philipp@7188
   125
 *  \param Gmask The green mask of the surface to create.
philipp@7188
   126
 *  \param Bmask The blue mask of the surface to create.
philipp@7188
   127
 *  \param Amask The alpha mask of the surface to create.
slouken@2275
   128
 */
slouken@2275
   129
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
slouken@2275
   130
    (Uint32 flags, int width, int height, int depth,
slouken@2275
   131
     Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
icculus@11197
   132
icculus@11197
   133
/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */
slouken@10482
   134
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
slouken@10482
   135
    (Uint32 flags, int width, int height, int depth, Uint32 format);
icculus@11197
   136
slouken@2275
   137
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
slouken@2275
   138
                                                              int width,
slouken@2275
   139
                                                              int height,
slouken@2275
   140
                                                              int depth,
slouken@2275
   141
                                                              int pitch,
slouken@2275
   142
                                                              Uint32 Rmask,
slouken@2275
   143
                                                              Uint32 Gmask,
slouken@2275
   144
                                                              Uint32 Bmask,
slouken@2275
   145
                                                              Uint32 Amask);
slouken@10482
   146
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom
slouken@10482
   147
    (void *pixels, int width, int height, int depth, int pitch, Uint32 format);
slouken@2275
   148
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
slouken@2275
   149
slouken@2275
   150
/**
slouken@3407
   151
 *  \brief Set the palette used by a surface.
slouken@7191
   152
 *
slouken@3407
   153
 *  \return 0, or -1 if the surface format doesn't use a palette.
slouken@7191
   154
 *
slouken@3407
   155
 *  \note A single palette can be shared with many surfaces.
slouken@2275
   156
 */
slouken@2275
   157
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
slouken@2275
   158
                                                  SDL_Palette * palette);
slouken@2275
   159
slouken@3341
   160
/**
slouken@3407
   161
 *  \brief Sets up a surface for directly accessing the pixels.
slouken@7191
   162
 *
slouken@3407
   163
 *  Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
slouken@7191
   164
 *  to and read from \c surface->pixels, using the pixel format stored in
slouken@7191
   165
 *  \c surface->format.  Once you are done accessing the surface, you should
slouken@3407
   166
 *  use SDL_UnlockSurface() to release it.
slouken@7191
   167
 *
slouken@3407
   168
 *  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
slouken@3407
   169
 *  to 0, then you can read and write to the surface at any time, and the
slouken@3407
   170
 *  pixel format of the surface will not change.
slouken@7191
   171
 *
slouken@3407
   172
 *  No operating system or library calls should be made between lock/unlock
slouken@3407
   173
 *  pairs, as critical system locks may be held during this time.
slouken@7191
   174
 *
slouken@3407
   175
 *  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
slouken@7191
   176
 *
slouken@3407
   177
 *  \sa SDL_UnlockSurface()
slouken@2275
   178
 */
slouken@2275
   179
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
slouken@3341
   180
/** \sa SDL_LockSurface() */
slouken@2275
   181
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
slouken@2275
   182
slouken@3341
   183
/**
slouken@4971
   184
 *  Load a surface from a seekable SDL data stream (memory or file).
slouken@7191
   185
 *
slouken@4971
   186
 *  If \c freesrc is non-zero, the stream will be closed after being read.
slouken@7191
   187
 *
slouken@3407
   188
 *  The new surface should be freed with SDL_FreeSurface().
slouken@7191
   189
 *
slouken@3407
   190
 *  \return the new surface, or NULL if there was an error.
slouken@2275
   191
 */
slouken@2275
   192
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
slouken@2275
   193
                                                    int freesrc);
slouken@2275
   194
slouken@3407
   195
/**
slouken@3407
   196
 *  Load a surface from a file.
slouken@7191
   197
 *
slouken@3407
   198
 *  Convenience macro.
slouken@3407
   199
 */
slouken@7191
   200
#define SDL_LoadBMP(file)   SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
slouken@2275
   201
slouken@3341
   202
/**
slouken@4971
   203
 *  Save a surface to a seekable SDL data stream (memory or file).
slouken@7191
   204
 *
slouken@10404
   205
 *  Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
slouken@10404
   206
 *  BMP directly. Other RGB formats with 8-bit or higher get converted to a
slouken@10404
   207
 *  24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
slouken@10404
   208
 *  surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
slouken@10404
   209
 *  not supported.
slouken@10404
   210
 *
slouken@4971
   211
 *  If \c freedst is non-zero, the stream will be closed after being written.
slouken@7191
   212
 *
slouken@3407
   213
 *  \return 0 if successful or -1 if there was an error.
slouken@2275
   214
 */
slouken@2275
   215
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
slouken@2275
   216
    (SDL_Surface * surface, SDL_RWops * dst, int freedst);
slouken@2275
   217
slouken@7191
   218
/**
slouken@3407
   219
 *  Save a surface to a file.
slouken@7191
   220
 *
slouken@3407
   221
 *  Convenience macro.
slouken@3407
   222
 */
slouken@2275
   223
#define SDL_SaveBMP(surface, file) \
slouken@7191
   224
        SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
slouken@2275
   225
slouken@3341
   226
/**
slouken@3407
   227
 *  \brief Sets the RLE acceleration hint for a surface.
slouken@7191
   228
 *
slouken@3407
   229
 *  \return 0 on success, or -1 if the surface is not valid
slouken@7191
   230
 *
slouken@3407
   231
 *  \note If RLE is enabled, colorkey and alpha blending blits are much faster,
slouken@3407
   232
 *        but the surface must be locked before directly accessing the pixels.
slouken@2275
   233
 */
slouken@2275
   234
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
slouken@2275
   235
                                              int flag);
slouken@2275
   236
slouken@3341
   237
/**
slouken@3407
   238
 *  \brief Sets the color key (transparent pixel) in a blittable surface.
slouken@7191
   239
 *
slouken@3407
   240
 *  \param surface The surface to update
slouken@6257
   241
 *  \param flag Non-zero to enable colorkey and 0 to disable colorkey
slouken@3407
   242
 *  \param key The transparent pixel in the native surface format
slouken@7191
   243
 *
slouken@3407
   244
 *  \return 0 on success, or -1 if the surface is not valid
slouken@6257
   245
 *
slouken@6257
   246
 *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
slouken@2275
   247
 */
slouken@2275
   248
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
slouken@3560
   249
                                            int flag, Uint32 key);
slouken@2275
   250
slouken@3341
   251
/**
slouken@12204
   252
 *  \brief Returns whether the surface has a color key
slouken@12204
   253
 *
slouken@12204
   254
 *  \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key
slouken@12204
   255
 */
slouken@12204
   256
extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
slouken@12204
   257
slouken@12204
   258
/**
slouken@3550
   259
 *  \brief Gets the color key (transparent pixel) in a blittable surface.
slouken@7191
   260
 *
slouken@3407
   261
 *  \param surface The surface to update
slouken@7191
   262
 *  \param key A pointer filled in with the transparent pixel in the native
slouken@3407
   263
 *             surface format
slouken@7191
   264
 *
slouken@7191
   265
 *  \return 0 on success, or -1 if the surface is not valid or colorkey is not
slouken@3407
   266
 *          enabled.
slouken@3103
   267
 */
slouken@3103
   268
extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
slouken@3103
   269
                                            Uint32 * key);
slouken@3103
   270
slouken@2275
   271
/**
slouken@3407
   272
 *  \brief Set an additional color value used in blit operations.
slouken@7191
   273
 *
slouken@3407
   274
 *  \param surface The surface to update.
slouken@4971
   275
 *  \param r The red color value multiplied into blit operations.
slouken@4971
   276
 *  \param g The green color value multiplied into blit operations.
slouken@4971
   277
 *  \param b The blue color value multiplied into blit operations.
slouken@7191
   278
 *
slouken@3407
   279
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@7191
   280
 *
slouken@3407
   281
 *  \sa SDL_GetSurfaceColorMod()
slouken@2275
   282
 */
slouken@2275
   283
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   284
                                                   Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   285
slouken@2275
   286
slouken@2275
   287
/**
slouken@3407
   288
 *  \brief Get the additional color value used in blit operations.
slouken@7191
   289
 *
slouken@3407
   290
 *  \param surface The surface to query.
slouken@4971
   291
 *  \param r A pointer filled in with the current red color value.
slouken@4971
   292
 *  \param g A pointer filled in with the current green color value.
slouken@4971
   293
 *  \param b A pointer filled in with the current blue color value.
slouken@7191
   294
 *
slouken@3407
   295
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@7191
   296
 *
slouken@3407
   297
 *  \sa SDL_SetSurfaceColorMod()
slouken@2275
   298
 */
slouken@2275
   299
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   300
                                                   Uint8 * r, Uint8 * g,
slouken@2275
   301
                                                   Uint8 * b);
slouken@2275
   302
slouken@2275
   303
/**
slouken@3407
   304
 *  \brief Set an additional alpha value used in blit operations.
slouken@7191
   305
 *
slouken@3407
   306
 *  \param surface The surface to update.
slouken@4971
   307
 *  \param alpha The alpha value multiplied into blit operations.
slouken@7191
   308
 *
slouken@3407
   309
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@7191
   310
 *
slouken@3407
   311
 *  \sa SDL_GetSurfaceAlphaMod()
slouken@2275
   312
 */
slouken@2275
   313
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   314
                                                   Uint8 alpha);
slouken@2275
   315
slouken@2275
   316
/**
slouken@3407
   317
 *  \brief Get the additional alpha value used in blit operations.
slouken@7191
   318
 *
slouken@3407
   319
 *  \param surface The surface to query.
slouken@4971
   320
 *  \param alpha A pointer filled in with the current alpha value.
slouken@7191
   321
 *
slouken@3407
   322
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@7191
   323
 *
slouken@3407
   324
 *  \sa SDL_SetSurfaceAlphaMod()
slouken@2275
   325
 */
slouken@2275
   326
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   327
                                                   Uint8 * alpha);
slouken@2275
   328
slouken@2275
   329
/**
slouken@3407
   330
 *  \brief Set the blend mode used for blit operations.
slouken@7191
   331
 *
slouken@3407
   332
 *  \param surface The surface to update.
slouken@3407
   333
 *  \param blendMode ::SDL_BlendMode to use for blit blending.
slouken@7191
   334
 *
slouken@3407
   335
 *  \return 0 on success, or -1 if the parameters are not valid.
slouken@7191
   336
 *
slouken@3407
   337
 *  \sa SDL_GetSurfaceBlendMode()
slouken@2275
   338
 */
slouken@2275
   339
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
slouken@4929
   340
                                                    SDL_BlendMode blendMode);
slouken@2275
   341
slouken@2275
   342
/**
slouken@3407
   343
 *  \brief Get the blend mode used for blit operations.
slouken@7191
   344
 *
slouken@3407
   345
 *  \param surface   The surface to query.
slouken@3407
   346
 *  \param blendMode A pointer filled in with the current blend mode.
slouken@7191
   347
 *
slouken@3407
   348
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@7191
   349
 *
slouken@3407
   350
 *  \sa SDL_SetSurfaceBlendMode()
slouken@2275
   351
 */
slouken@2275
   352
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
slouken@4929
   353
                                                    SDL_BlendMode *blendMode);
slouken@2275
   354
slouken@2275
   355
/**
slouken@3407
   356
 *  Sets the clipping rectangle for the destination surface in a blit.
slouken@7191
   357
 *
slouken@3407
   358
 *  If the clip rectangle is NULL, clipping will be disabled.
slouken@7191
   359
 *
slouken@3407
   360
 *  If the clip rectangle doesn't intersect the surface, the function will
slouken@3407
   361
 *  return SDL_FALSE and blits will be completely clipped.  Otherwise the
slouken@3407
   362
 *  function returns SDL_TRUE and blits to the surface will be clipped to
slouken@3407
   363
 *  the intersection of the surface area and the clipping rectangle.
slouken@7191
   364
 *
slouken@3407
   365
 *  Note that blits are automatically clipped to the edges of the source
slouken@3407
   366
 *  and destination surfaces.
slouken@2275
   367
 */
slouken@2275
   368
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
slouken@2275
   369
                                                 const SDL_Rect * rect);
slouken@2275
   370
slouken@3341
   371
/**
slouken@3407
   372
 *  Gets the clipping rectangle for the destination surface in a blit.
slouken@7191
   373
 *
slouken@3407
   374
 *  \c rect must be a pointer to a valid rectangle which will be filled
slouken@3407
   375
 *  with the correct values.
slouken@2275
   376
 */
slouken@2275
   377
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
slouken@2275
   378
                                             SDL_Rect * rect);
slouken@2275
   379
slouken@11289
   380
/*
slouken@11289
   381
 * Creates a new surface identical to the existing surface
slouken@11289
   382
 */
slouken@11289
   383
extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface);
slouken@11289
   384
slouken@3341
   385
/**
slouken@7191
   386
 *  Creates a new surface of the specified format, and then copies and maps
slouken@7191
   387
 *  the given surface to it so the blit of the converted surface will be as
slouken@3407
   388
 *  fast as possible.  If this function fails, it returns NULL.
slouken@7191
   389
 *
slouken@7191
   390
 *  The \c flags parameter is passed to SDL_CreateRGBSurface() and has those
slouken@3407
   391
 *  semantics.  You can also pass ::SDL_RLEACCEL in the flags parameter and
slouken@3407
   392
 *  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
slouken@3407
   393
 *  surface.
slouken@2275
   394
 */
slouken@2275
   395
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
icculus@7725
   396
    (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
slouken@5375
   397
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
slouken@5375
   398
    (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
slouken@2275
   399
slouken@3341
   400
/**
slouken@3434
   401
 * \brief Copy a block of pixels of one format to another format
slouken@7191
   402
 *
slouken@6041
   403
 *  \return 0 on success, or -1 if there was an error
slouken@3434
   404
 */
slouken@3434
   405
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
slouken@3434
   406
                                              Uint32 src_format,
slouken@3434
   407
                                              const void * src, int src_pitch,
slouken@3434
   408
                                              Uint32 dst_format,
slouken@3434
   409
                                              void * dst, int dst_pitch);
slouken@3434
   410
slouken@3434
   411
/**
slouken@3407
   412
 *  Performs a fast fill of the given rectangle with \c color.
slouken@7191
   413
 *
slouken@3536
   414
 *  If \c rect is NULL, the whole surface will be filled with \c color.
slouken@7191
   415
 *
slouken@7191
   416
 *  The color should be a pixel of the format used by the surface, and
slouken@3407
   417
 *  can be generated by the SDL_MapRGB() function.
slouken@7191
   418
 *
slouken@3407
   419
 *  \return 0 on success, or -1 on error.
slouken@2275
   420
 */
slouken@2275
   421
extern DECLSPEC int SDLCALL SDL_FillRect
slouken@3536
   422
    (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
slouken@3536
   423
extern DECLSPEC int SDLCALL SDL_FillRects
slouken@5297
   424
    (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
slouken@2275
   425
slouken@3341
   426
/**
slouken@3407
   427
 *  Performs a fast blit from the source surface to the destination surface.
slouken@7191
   428
 *
slouken@3407
   429
 *  This assumes that the source and destination rectangles are
slouken@3407
   430
 *  the same size.  If either \c srcrect or \c dstrect are NULL, the entire
slouken@3407
   431
 *  surface (\c src or \c dst) is copied.  The final blit rectangles are saved
slouken@3407
   432
 *  in \c srcrect and \c dstrect after all clipping is performed.
slouken@7191
   433
 *
slouken@3407
   434
 *  \return If the blit is successful, it returns 0, otherwise it returns -1.
slouken@2275
   435
 *
slouken@3407
   436
 *  The blit function should not be called on a locked surface.
slouken@2275
   437
 *
slouken@7502
   438
 *  The blit semantics for surfaces with and without blending and colorkey
slouken@3407
   439
 *  are defined as follows:
slouken@3407
   440
 *  \verbatim
slouken@3407
   441
    RGBA->RGB:
slouken@7502
   442
      Source surface blend mode set to SDL_BLENDMODE_BLEND:
slouken@7502
   443
        alpha-blend (using the source alpha-channel and per-surface alpha)
slouken@3407
   444
        SDL_SRCCOLORKEY ignored.
slouken@7502
   445
      Source surface blend mode set to SDL_BLENDMODE_NONE:
slouken@3407
   446
        copy RGB.
slouken@3407
   447
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   448
        RGB values of the source color key, ignoring alpha in the
slouken@3407
   449
        comparison.
slouken@7191
   450
slouken@3407
   451
    RGB->RGBA:
slouken@7502
   452
      Source surface blend mode set to SDL_BLENDMODE_BLEND:
slouken@7502
   453
        alpha-blend (using the source per-surface alpha)
slouken@7502
   454
      Source surface blend mode set to SDL_BLENDMODE_NONE:
slouken@3407
   455
        copy RGB, set destination alpha to source per-surface alpha value.
slouken@3407
   456
      both:
slouken@3407
   457
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   458
        source color key.
slouken@7191
   459
slouken@3407
   460
    RGBA->RGBA:
slouken@7502
   461
      Source surface blend mode set to SDL_BLENDMODE_BLEND:
slouken@7502
   462
        alpha-blend (using the source alpha-channel and per-surface alpha)
slouken@3407
   463
        SDL_SRCCOLORKEY ignored.
slouken@7502
   464
      Source surface blend mode set to SDL_BLENDMODE_NONE:
slouken@3407
   465
        copy all of RGBA to the destination.
slouken@3407
   466
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   467
        RGB values of the source color key, ignoring alpha in the
slouken@7502
   468
        comparison.
slouken@7191
   469
slouken@7191
   470
    RGB->RGB:
slouken@7502
   471
      Source surface blend mode set to SDL_BLENDMODE_BLEND:
slouken@7502
   472
        alpha-blend (using the source per-surface alpha)
slouken@7502
   473
      Source surface blend mode set to SDL_BLENDMODE_NONE:
slouken@3407
   474
        copy RGB.
slouken@3407
   475
      both:
slouken@3407
   476
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   477
        source color key.
slouken@3407
   478
    \endverbatim
slouken@7191
   479
 *
slouken@3407
   480
 *  You should call SDL_BlitSurface() unless you know exactly how SDL
slouken@3407
   481
 *  blitting works internally and how to use the other blit functions.
slouken@2275
   482
 */
slouken@2275
   483
#define SDL_BlitSurface SDL_UpperBlit
slouken@2275
   484
slouken@3407
   485
/**
slouken@3407
   486
 *  This is the public blit function, SDL_BlitSurface(), and it performs
slouken@3341
   487
 *  rectangle validation and clipping before passing it to SDL_LowerBlit()
slouken@3341
   488
 */
slouken@2275
   489
extern DECLSPEC int SDLCALL SDL_UpperBlit
slouken@4949
   490
    (SDL_Surface * src, const SDL_Rect * srcrect,
slouken@2275
   491
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@3341
   492
slouken@3407
   493
/**
slouken@3407
   494
 *  This is a semi-private blit function and it performs low-level surface
slouken@3341
   495
 *  blitting only.
slouken@3341
   496
 */
slouken@2275
   497
extern DECLSPEC int SDLCALL SDL_LowerBlit
slouken@2275
   498
    (SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
   499
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
   500
slouken@2275
   501
/**
slouken@3407
   502
 *  \brief Perform a fast, low quality, stretch blit between two surfaces of the
slouken@3407
   503
 *         same pixel format.
slouken@7191
   504
 *
slouken@3407
   505
 *  \note This function uses a static buffer, and is not thread-safe.
slouken@2275
   506
 */
slouken@2275
   507
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
slouken@2828
   508
                                            const SDL_Rect * srcrect,
slouken@2275
   509
                                            SDL_Surface * dst,
slouken@2828
   510
                                            const SDL_Rect * dstrect);
slouken@2275
   511
ken@5499
   512
#define SDL_BlitScaled SDL_UpperBlitScaled
ken@5499
   513
ken@5296
   514
/**
ken@5499
   515
 *  This is the public scaled blit function, SDL_BlitScaled(), and it performs
ken@5499
   516
 *  rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
ken@5296
   517
 */
ken@5499
   518
extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
ken@5296
   519
    (SDL_Surface * src, const SDL_Rect * srcrect,
ken@5499
   520
    SDL_Surface * dst, SDL_Rect * dstrect);
ken@5499
   521
ken@5499
   522
/**
ken@5499
   523
 *  This is a semi-private blit function and it performs low-level surface
ken@5499
   524
 *  scaled blitting only.
ken@5499
   525
 */
ken@5499
   526
extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
ken@5499
   527
    (SDL_Surface * src, SDL_Rect * srcrect,
ken@5499
   528
    SDL_Surface * dst, SDL_Rect * dstrect);
ken@5296
   529
slouken@11702
   530
/**
slouken@11702
   531
 *  \brief Set the YUV conversion mode
slouken@11702
   532
 */
slouken@11702
   533
extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
slouken@11702
   534
slouken@11702
   535
/**
slouken@11702
   536
 *  \brief Get the YUV conversion mode
slouken@11702
   537
 */
slouken@11702
   538
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
slouken@11702
   539
slouken@11702
   540
/**
slouken@11702
   541
 *  \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
slouken@11702
   542
 */
slouken@11702
   543
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
ken@5296
   544
slouken@2275
   545
/* Ends C function definitions when using C++ */
slouken@2275
   546
#ifdef __cplusplus
slouken@2275
   547
}
slouken@2275
   548
#endif
slouken@2275
   549
#include "close_code.h"
slouken@2275
   550
slouken@10638
   551
#endif /* SDL_surface_h_ */
slouken@2275
   552
slouken@2275
   553
/* vi: set ts=4 sw=4 expandtab: */