Feature #112 » 0003-SDL3_gfx-Stop-using-SDL_CreateRGBSurface.patch
dependencies/SDL3_gfx/SDL3_rotozoom.c | ||
---|---|---|
newHeight = src->h;
|
||
}
|
||
dst = SDL_CreateRGBSurface( src->flags, newWidth, newHeight, src->format->BitsPerPixel,
|
||
src->format->Rmask,
|
||
src->format->Gmask,
|
||
src->format->Bmask,
|
||
src->format->Amask);
|
||
dst = SDL_CreateSurface( newWidth, newHeight, SDL_PIXELFORMAT_RGBA8888);
|
||
if(!dst) {
|
||
SDL_SetError("Could not create destination surface");
|
||
return NULL;
|
||
... | ... | |
double zoominv;
|
||
double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
|
||
int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
|
||
int is32bit;
|
||
int i, src_converted;
|
||
int flipx,flipy;
|
||
... | ... | |
/*
|
||
* Determine if source surface is 32bit or 8bit
|
||
*/
|
||
is32bit = (src->format->BitsPerPixel == 32);
|
||
if ((is32bit) || (src->format->BitsPerPixel == 8)) {
|
||
if ((src->format->BitsPerPixel == 32) || (src->format->BitsPerPixel == 8)) {
|
||
/*
|
||
* Use source surface 'as is'
|
||
*/
|
||
... | ... | |
* New source surface is 32bit with a defined RGBA ordering
|
||
*/
|
||
rz_src =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
|
||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||
#else
|
||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||
#endif
|
||
);
|
||
SDL_CreateSurface(src->w, src->h, SDL_PIXELFORMAT_RGBA8888);
|
||
SDL_BlitSurface(src, NULL, rz_src, NULL);
|
||
src_converted = 1;
|
||
is32bit = 1;
|
||
}
|
||
/*
|
||
... | ... | |
* Alloc space to completely contain the rotated surface
|
||
*/
|
||
rz_dst = NULL;
|
||
if (is32bit) {
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
|
||
rz_src->format->Rmask, rz_src->format->Gmask,
|
||
rz_src->format->Bmask, rz_src->format->Amask);
|
||
} else {
|
||
/*
|
||
* Target surface is 8bit
|
||
*/
|
||
rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||
}
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
rz_src->format->format);
|
||
/* Check target */
|
||
if (rz_dst == NULL)
|
||
... | ... | |
/*
|
||
* Check which kind of surface we have
|
||
*/
|
||
if (is32bit) {
|
||
/*
|
||
* Call the 32bit transformation routine to do the rotation (using alpha)
|
||
*/
|
||
_transformSurfaceRGBA(rz_src, rz_dst, dstwidthhalf, dstheighthalf,
|
||
(int) (sanglezoominv), (int) (canglezoominv),
|
||
flipx, flipy,
|
||
smooth);
|
||
} else {
|
||
/*
|
||
* Copy palette and colorkey info
|
||
*/
|
||
for (i = 0; i < rz_src->format->palette->ncolors; i++) {
|
||
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
|
||
}
|
||
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
|
||
/*
|
||
* Call the 8bit transformation routine to do the rotation
|
||
*/
|
||
transformSurfaceY(rz_src, rz_dst, dstwidthhalf, dstheighthalf,
|
||
(int) (sanglezoominv), (int) (canglezoominv),
|
||
flipx, flipy);
|
||
}
|
||
/*
|
||
* Call the 32bit transformation routine to do the rotation (using alpha)
|
||
*/
|
||
_transformSurfaceRGBA(rz_src, rz_dst, dstwidthhalf, dstheighthalf,
|
||
(int) (sanglezoominv), (int) (canglezoominv),
|
||
flipx, flipy,
|
||
smooth);
|
||
/*
|
||
* Unlock source surface
|
||
*/
|
||
... | ... | |
* Alloc space to completely contain the zoomed surface
|
||
*/
|
||
rz_dst = NULL;
|
||
if (is32bit) {
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
|
||
rz_src->format->Rmask, rz_src->format->Gmask,
|
||
rz_src->format->Bmask, rz_src->format->Amask);
|
||
} else {
|
||
/*
|
||
* Target surface is 8bit
|
||
*/
|
||
rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||
}
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
rz_src->format->format);
|
||
/* Check target */
|
||
if (rz_dst == NULL)
|
||
... | ... | |
/*
|
||
* Check which kind of surface we have
|
||
*/
|
||
if (is32bit) {
|
||
/*
|
||
* Call the 32bit transformation routine to do the zooming (using alpha)
|
||
*/
|
||
_zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
|
||
} else {
|
||
/*
|
||
* Copy palette and colorkey info
|
||
*/
|
||
for (i = 0; i < rz_src->format->palette->ncolors; i++) {
|
||
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
|
||
}
|
||
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
|
||
/*
|
||
* Call the 8bit transformation routine to do the zooming
|
||
*/
|
||
_zoomSurfaceY(rz_src, rz_dst, flipx, flipy);
|
||
}
|
||
/*
|
||
* Call the 32bit transformation routine to do the zooming (using alpha)
|
||
*/
|
||
_zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
|
||
/*
|
||
* Unlock source surface
|
||
... | ... | |
SDL_Surface *rz_src;
|
||
SDL_Surface *rz_dst;
|
||
int dstwidth, dstheight;
|
||
int is32bit;
|
||
int i, src_converted;
|
||
int flipx, flipy;
|
||
... | ... | |
/*
|
||
* Determine if source surface is 32bit or 8bit
|
||
*/
|
||
is32bit = (src->format->BitsPerPixel == 32);
|
||
if ((is32bit) || (src->format->BitsPerPixel == 8)) {
|
||
if ((src->format->BitsPerPixel == 32) || (src->format->BitsPerPixel == 8)) {
|
||
/*
|
||
* Use source surface 'as is'
|
||
*/
|
||
... | ... | |
* New source surface is 32bit with a defined RGBA ordering
|
||
*/
|
||
rz_src =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
|
||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||
#else
|
||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||
#endif
|
||
);
|
||
SDL_CreateSurface(src->w, src->h,
|
||
SDL_PIXELFORMAT_RGBA8888);
|
||
if (rz_src == NULL) {
|
||
return NULL;
|
||
}
|
||
SDL_BlitSurface(src, NULL, rz_src, NULL);
|
||
src_converted = 1;
|
||
is32bit = 1;
|
||
}
|
||
flipx = (zoomx<0.0);
|
||
... | ... | |
* Alloc space to completely contain the zoomed surface
|
||
*/
|
||
rz_dst = NULL;
|
||
if (is32bit) {
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
|
||
rz_src->format->Rmask, rz_src->format->Gmask,
|
||
rz_src->format->Bmask, rz_src->format->Amask);
|
||
} else {
|
||
/*
|
||
* Target surface is 8bit
|
||
*/
|
||
rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||
}
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
rz_src->format->format);
|
||
/* Check target */
|
||
if (rz_dst == NULL) {
|
||
... | ... | |
/*
|
||
* Check which kind of surface we have
|
||
*/
|
||
if (is32bit) {
|
||
/*
|
||
* Call the 32bit transformation routine to do the zooming (using alpha)
|
||
*/
|
||
_zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
|
||
} else {
|
||
/*
|
||
* Copy palette and colorkey info
|
||
*/
|
||
for (i = 0; i < rz_src->format->palette->ncolors; i++) {
|
||
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
|
||
}
|
||
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
|
||
/*
|
||
* Call the 8bit transformation routine to do the zooming
|
||
*/
|
||
_zoomSurfaceY(rz_src, rz_dst, flipx, flipy);
|
||
}
|
||
/*
|
||
* Call the 32bit transformation routine to do the zooming (using alpha)
|
||
*/
|
||
_zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
|
||
/*
|
||
* Unlock source surface
|
||
*/
|
||
... | ... | |
SDL_Surface *rz_src;
|
||
SDL_Surface *rz_dst = NULL;
|
||
int dstwidth, dstheight;
|
||
int is32bit;
|
||
int i, src_converted;
|
||
int haveError = 0;
|
||
... | ... | |
/*
|
||
* Determine if source surface is 32bit or 8bit
|
||
*/
|
||
is32bit = (src->format->BitsPerPixel == 32);
|
||
if ((is32bit) || (src->format->BitsPerPixel == 8)) {
|
||
if ((src->format->BitsPerPixel == 32) || (src->format->BitsPerPixel == 8)) {
|
||
/*
|
||
* Use source surface 'as is'
|
||
*/
|
||
... | ... | |
src_converted = 0;
|
||
} else {
|
||
/*
|
||
* New source surface is 32bit with a defined RGBA ordering
|
||
* New source surface is 32bit with a defined RGBA ordering
|
||
*/
|
||
rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
|
||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||
#else
|
||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||
#endif
|
||
);
|
||
rz_src = SDL_CreateSurface(src->w, src->h,
|
||
SDL_PIXELFORMAT_RGBA8888);
|
||
if (rz_src==NULL) {
|
||
haveError = 1;
|
||
goto exitShrinkSurface;
|
||
... | ... | |
SDL_BlitSurface(src, NULL, rz_src, NULL);
|
||
src_converted = 1;
|
||
is32bit = 1;
|
||
}
|
||
/*
|
||
... | ... | |
* Alloc space to completely contain the shrunken surface
|
||
* (with added guard rows)
|
||
*/
|
||
if (is32bit==1) {
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
|
||
rz_src->format->Rmask, rz_src->format->Gmask,
|
||
rz_src->format->Bmask, rz_src->format->Amask);
|
||
} else {
|
||
/*
|
||
* Target surface is 8bit
|
||
*/
|
||
rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||
}
|
||
/*
|
||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||
*/
|
||
rz_dst =
|
||
SDL_CreateSurface(dstwidth, dstheight + GUARD_ROWS,
|
||
rz_src->format->format);
|
||
/* Check target */
|
||
if (rz_dst == NULL) {
|
||
... | ... | |
/*
|
||
* Check which kind of surface we have
|
||
*/
|
||
if (is32bit==1) {
|
||
/*
|
||
* Call the 32bit transformation routine to do the shrinking (using alpha)
|
||
*/
|
||
result = _shrinkSurfaceRGBA(rz_src, rz_dst, factorx, factory);
|
||
if ((result!=0) || (rz_dst==NULL)) {
|
||
haveError = 1;
|
||
goto exitShrinkSurface;
|
||
}
|
||
} else {
|
||
/*
|
||
* Copy palette and colorkey info
|
||
*/
|
||
for (i = 0; i < rz_src->format->palette->ncolors; i++) {
|
||
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
|
||
}
|
||
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
|
||
/*
|
||
* Call the 8bit transformation routine to do the shrinking
|
||
*/
|
||
result = _shrinkSurfaceY(rz_src, rz_dst, factorx, factory);
|
||
if (result!=0) {
|
||
haveError = 1;
|
||
goto exitShrinkSurface;
|
||
}
|
||
}
|
||
/*
|
||
* Call the 32bit transformation routine to do the shrinking (using alpha)
|
||
*/
|
||
result = _shrinkSurfaceRGBA(rz_src, rz_dst, factorx, factory);
|
||
if ((result!=0) || (rz_dst==NULL)) {
|
||
haveError = 1;
|
||
goto exitShrinkSurface;
|
||
}
|
||
exitShrinkSurface:
|
||
if (rz_src!=NULL) {
|
- « Previous
- 1
- 2
- Next »