SDL_surface.h 24 KB

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