src/gfx/SDL_rotozoom.c
/*! 

\brief Internal 8 bit Zoomer without smoothing.

Zooms 8bit palette/Y 'src' surface to 'dst' surface.
Assumes src and dst surfaces are of 8 bit depth.
Assumes dst surface was allocated with the correct dimensions.

\param src The surface to zoom (input).
\param dst The zoomed surface (output).
\param flipx Flag indicating if the image should be horizontally flipped.
\param flipy Flag indicating if the image should be vertically flipped.

\return 0 for success or -1 for error.
*/
\brief Internal 8 bit Zoomer without smoothing.
Zooms 8bit palette/Y 'src' surface to 'dst' surface.
Assumes src and dst surfaces are of 8 bit depth.
Assumes dst surface was allocated with the correct dimensions.

\param src The surface to zoom (input).
\param dst The zoomed surface (output).
\param flipx Flag indicating if the image should be horizontally flipped.
\param flipy Flag indicating if the image should be vertically flipped.

\return 0 for success or -1 for error.
\ brief Internal 8 bit Zoomer without smoothing . Zooms 8bit palette / Y ' src ' surface to ' dst ' surface . Assumes src and dst surfaces are of 8 bit depth . Assumes dst surface was allocated with the correct dimensions . \ param src The surface to zoom ( input ) . \ param dst The zoomed surface ( output ) . \ param flipx Flag indicating if the image should be horizontally flipped . \ param flipy Flag indicating if the image should be vertically flipped . \ return 0 for success or - 1 for error .
int _zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy)
{
	int x, y;
	Uint32 *sax, *say, *csax, *csay;
	int csx, csy;
	Uint8 *sp, *dp, *csp;
	int dgap;
	if ((sax = (Uint32 *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
		return (-1);
	}
	if ((say = (Uint32 *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
		free(sax);
		return (-1);
	}
	sp = csp = (Uint8 *) src->pixels;
	dp = (Uint8 *) dst->pixels;
	dgap = dst->pitch - dst->w;
	if (flipx) csp += (src->w-1);
	if (flipy) csp  = ( (Uint8*)csp + src->pitch*(src->h-1) );
	csx = 0;
	csax = sax;
	for (x = 0; x < dst->w; x++) {
		csx += src->w;
		*csax = 0;
		while (csx >= dst->w) {
			csx -= dst->w;
			(*csax)++;
		}
		(*csax) = (*csax) * (flipx ? -1 : 1);
		csax++;
	}
	csy = 0;
	csay = say;
	for (y = 0; y < dst->h; y++) {
		csy += src->h;
		*csay = 0;
		while (csy >= dst->h) {
			csy -= dst->h;
			(*csay)++;
		}
		(*csay) = (*csay) * (flipy ? -1 : 1);
		csay++;
	}
	csay = say;
	for (y = 0; y < dst->h; y++) {
		csax = sax;
		sp = csp;
		for (x = 0; x < dst->w; x++) {
			*dp = *sp;
			sp += (*csax);
			csax++;
			dp++;
		}
		csp += ((*csay) * src->pitch);
		csay++;
		dp += dgap;
	}
	free(sax);
	free(say);
	return (0);
}
int _zoomSurfaceY ( SDL_Surface * src , SDL_Surface * dst , int flipx , int flipy ) { int x , y ; Uint32 * sax , * say , * csax , * csay ; int csx , csy ; Uint8 * sp , * dp , * csp ; int dgap ; if ( ( sax = ( Uint32 * ) malloc ( ( dst -> w + 1 ) * sizeof ( Uint32 ) ) ) == NULL ) { return ( -1 ) ; } if ( ( say = ( Uint32 * ) malloc ( ( dst -> h + 1 ) * sizeof ( Uint32 ) ) ) == NULL ) { free ( sax ) ; return ( -1 ) ; } sp = csp = ( Uint8 * ) src -> pixels ; dp = ( Uint8 * ) dst -> pixels ; dgap = dst -> pitch - dst -> w ; if ( flipx ) csp += ( src -> w - 1 ) ; if ( flipy ) csp = ( ( Uint8 * ) csp + src -> pitch * ( src -> h - 1 ) ) ; csx = 0 ; csax = sax ; for ( x = 0 ; x < dst -> w ; x ++ ) { csx += src -> w ; * csax = 0 ; while ( csx >= dst -> w ) { csx -= dst -> w ; ( * csax ) ++ ; } ( * csax ) = ( * csax ) * ( flipx ? -1 : 1 ) ; csax ++ ; } csy = 0 ; csay = say ; for ( y = 0 ; y < dst -> h ; y ++ ) { csy += src -> h ; * csay = 0 ; while ( csy >= dst -> h ) { csy -= dst -> h ; ( * csay ) ++ ; } ( * csay ) = ( * csay ) * ( flipy ? -1 : 1 ) ; csay ++ ; } csay = say ; for ( y = 0 ; y < dst -> h ; y ++ ) { csax = sax ; sp = csp ; for ( x = 0 ; x < dst -> w ; x ++ ) { * dp = * sp ; sp += ( * csax ) ; csax ++ ; dp ++ ; } csp += ( ( * csay ) * src -> pitch ) ; csay ++ ; dp += dgap ; } free ( sax ) ; free ( say ) ; return ( 0 ) ; }
\brief Internal 8 bit Zoomer without smoothing.
\ brief Internal 8 bit Zoomer without smoothing .
/*
	* Allocate memory for row increments 
	*/ /*
	* Pointer setup 
	*/ /*
	* Precalculate row increments 
	*/ /*
	* Draw 
	*/ /*
			* Draw 
			*/ /*
			* Advance source pointers 
			*/ /*
			* Advance destination pointer 
			*/ /*
		* Advance source pointer (for row) 
		*/ /*
		* Advance destination pointers 
		*/ /*
	* Remove temp arrays 
	*/