Go to the documentation of this file.
21 #include "../SDL_internal.h"
33 sizeof(
int) ==
sizeof(
Sint32) &&
sizeof(
size_t) >=
sizeof(
Sint32));
49 pitch = (pitch + 7) / 8;
52 pitch = (pitch + 1) / 2;
57 pitch = (pitch + 3) & ~3;
220 return SDL_SetError(
"SDL_SetSurfacePalette() passed a NULL surface");
330 switch (
surface->format->BytesPerPixel) {
344 if ((*spot &
mask) == ckey) {
382 if ((*spot &
mask) == ckey) {
426 if (
r != 0xFF ||
g != 0xFF ||
b != 0xFF) {
577 surface->clip_rect = full_rect;
607 if ((
src->map->dst !=
dst) ||
608 (
dst->format->palette &&
609 src->map->dst_palette_version !=
dst->format->palette->version) ||
610 (
src->format->palette &&
611 src->map->src_palette_version !=
src->format->palette->version)) {
621 return (
src->map->blit(
src, srcrect,
dst, dstrect));
630 int srcx, srcy,
w,
h;
634 return SDL_SetError(
"SDL_UpperBlit: passed a NULL surface");
636 if (
src->locked ||
dst->locked) {
637 return SDL_SetError(
"Surfaces must not be locked during blit");
641 if (dstrect ==
NULL) {
642 fulldst.
x = fulldst.
y = 0;
659 maxw =
src->w - srcx;
670 maxh =
src->h - srcy;
685 dx = clip->
x - dstrect->
x;
691 dx = dstrect->
x +
w - clip->
x - clip->
w;
695 dy = clip->
y - dstrect->
y;
701 dy = dstrect->
y +
h - clip->
y - clip->
h;
712 if (
w > 0 &&
h > 0) {
716 sr.
w = dstrect->
w =
w;
717 sr.
h = dstrect->
h =
h;
720 dstrect->
w = dstrect->
h = 0;
728 double src_x0, src_y0, src_x1, src_y1;
729 double dst_x0, dst_y0, dst_x1, dst_y1;
731 double scaling_w, scaling_h;
737 return SDL_SetError(
"SDL_UpperBlitScaled: passed a NULL surface");
739 if (
src->locked ||
dst->locked) {
740 return SDL_SetError(
"Surfaces must not be locked during blit");
743 if (
NULL == srcrect) {
751 if (
NULL == dstrect) {
759 if (dst_w == src_w && dst_h == src_h) {
764 scaling_w = (double)dst_w / src_w;
765 scaling_h = (double)dst_h / src_h;
767 if (
NULL == dstrect) {
775 dst_x1 = dst_x0 + dst_w - 1;
776 dst_y1 = dst_y0 + dst_h - 1;
779 if (
NULL == srcrect) {
787 src_x1 = src_x0 + src_w - 1;
788 src_y1 = src_y0 + src_h - 1;
793 dst_x0 -= src_x0 * scaling_w;
797 if (src_x1 >=
src->w) {
798 dst_x1 -= (src_x1 -
src->w + 1) * scaling_w;
803 dst_y0 -= src_y0 * scaling_h;
807 if (src_y1 >=
src->h) {
808 dst_y1 -= (src_y1 -
src->h + 1) * scaling_h;
816 dst_x0 -=
dst->clip_rect.x;
817 dst_x1 -=
dst->clip_rect.x;
818 dst_y0 -=
dst->clip_rect.y;
819 dst_y1 -=
dst->clip_rect.y;
822 src_x0 -= dst_x0 / scaling_w;
826 if (dst_x1 >=
dst->clip_rect.w) {
827 src_x1 -= (dst_x1 -
dst->clip_rect.w + 1) / scaling_w;
828 dst_x1 =
dst->clip_rect.w - 1;
832 src_y0 -= dst_y0 / scaling_h;
836 if (dst_y1 >=
dst->clip_rect.h) {
837 src_y1 -= (dst_y1 -
dst->clip_rect.h + 1) / scaling_h;
838 dst_y1 =
dst->clip_rect.h - 1;
842 dst_x0 +=
dst->clip_rect.x;
843 dst_x1 +=
dst->clip_rect.x;
844 dst_y0 +=
dst->clip_rect.y;
845 dst_y1 +=
dst->clip_rect.y;
854 final_dst.
w = (int)
SDL_floor(dst_x1 - dst_x0 + 1.5);
855 final_dst.
h = (int)
SDL_floor(dst_y1 - dst_y0 + 1.5);
863 *dstrect = final_dst;
865 if (final_dst.
w == 0 || final_dst.
h == 0 ||
866 final_src.
w <= 0 || final_src.
h <= 0) {
882 static const Uint32 complex_copy_flags = (
893 if ( !(
src->map->info.flags & complex_copy_flags) &&
894 src->format->format ==
dst->format->format &&
975 for (
i = 0;
i <
format->palette->ncolors; ++
i) {
976 if ((
format->palette->colors[
i].r != 0xFF) ||
977 (
format->palette->colors[
i].g != 0xFF) ||
978 (
format->palette->colors[
i].b != 0xFF))
981 if (
i ==
format->palette->ncolors) {
992 if (convert ==
NULL) {
1005 copy_flags =
surface->map->info.flags;
1006 copy_color.
r =
surface->map->info.r;
1007 copy_color.
g =
surface->map->info.g;
1008 copy_color.
b =
surface->map->info.b;
1009 copy_color.
a =
surface->map->info.a;
1034 surface->map->info.r = copy_color.
r;
1035 surface->map->info.g = copy_color.
g;
1036 surface->map->info.b = copy_color.
b;
1037 surface->map->info.a = copy_color.
a;
1038 surface->map->info.flags = copy_flags;
1051 if (
surface->format->palette) {
1053 surface->format->palette->ncolors <=
format->palette->ncolors &&
1058 }
else if (
format->Amask) {
1068 if (set_colorkey_by_color) {
1071 int converted_colorkey = 0;
1080 if (
surface->format->palette) {
1163 blitmap->
info.
r = 0xFF;
1164 blitmap->
info.
g = 0xFF;
1165 blitmap->
info.
b = 0xFF;
1166 blitmap->
info.
a = 0xFF;
1178 Uint32 src_format,
const void *
src,
int src_pitch,
1179 Uint32 dst_format,
void *
dst,
int dst_pitch)
1185 void *nonconst_src = (
void *)
src;
1204 if (src_format == dst_format) {
1218 &src_surface, &src_fmt, &src_blitmap)) {
1222 &dst_surface, &dst_fmt, &dst_blitmap)) {
1248 if (--
surface->refcount > 0) {
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define SDL_BITSPERPIXEL(X)
static SDL_BlendMode blendMode
A collection of pixels used in software blitting.
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int)==sizeof(Sint32) &&sizeof(size_t) >=sizeof(Sint32))
int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format, Uint32 flags)
SDL_bool SDL_HasColorKey(SDL_Surface *surface)
Returns whether the surface has a color key.
#define SDL_COPY_RLE_COLORKEY
GLboolean GLboolean GLboolean b
GLint GLint GLsizei width
int SDL_ConvertPixels(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Copy a block of pixels of one format to another format.
void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void *pixels, int pitch, SDL_Surface *surface, SDL_PixelFormat *format, SDL_BlitMap *blitmap)
GLdouble GLdouble GLdouble r
#define SDL_MasksToPixelFormatEnum
SDL_BlitMap * SDL_AllocBlitMap(void)
#define SDL_InvalidParamError(param)
int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
#define SDL_IntersectRect
#define SDL_COPY_COLORKEY
SDL_Surface * SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
#define SDL_ISPIXELFORMAT_INDEXED(format)
GLfloat GLfloat GLfloat GLfloat h
SDL_Surface * SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format, Uint32 flags)
#define SDL_COPY_RLE_DESIRED
GLfloat GLfloat GLfloat alpha
int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
GLint GLint GLint GLint GLint x
SDL_Surface * SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
GLint GLint GLsizei GLsizei height
int SDL_RLESurface(SDL_Surface *surface)
SDL_Surface * SDL_DuplicateSurface(SDL_Surface *surface)
int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
SDL_Surface * SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
GLint GLint GLsizei GLsizei GLsizei depth
void SDL_UnlockSurface(SDL_Surface *surface)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
#define SDL_COPY_MODULATE_ALPHA
SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
SDL_Surface * SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
#define SDL_COPY_RLE_ALPHAKEY
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.
int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
static int SDL_CalculatePitch(Uint32 format, int width)
int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
#define SDL_ISPIXELFORMAT_FOURCC(format)
#define SDL_BYTESPERPIXEL(X)
void SDL_InvalidateMap(SDL_BlitMap *map)
A rectangle, with the origin at the upper left (integer).
#define SDL_MAX_SINT32
A signed 32-bit integer type.
int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
int SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
void SDL_FreeSurface(SDL_Surface *surface)
#define SDL_COPY_MODULATE_COLOR
int SDL_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
#define SDL_Unsupported()
void SDL_FreeBlitMap(SDL_BlitMap *map)
static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alpha)
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
#define SDL_SetPixelFormatPalette
int SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
GLubyte GLubyte GLubyte GLubyte w
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)