test/testalpha.c
changeset 691 609543e2b3a1
parent 0 74212992fb08
child 886 05c551e5bc64
     1.1 --- a/test/testalpha.c	Sat Aug 23 23:12:19 2003 +0000
     1.2 +++ b/test/testalpha.c	Sat Aug 23 23:18:49 2003 +0000
     1.3 @@ -279,11 +279,15 @@
     1.4  	Uint8  video_bpp;
     1.5  	Uint32 videoflags;
     1.6  	Uint8 *buffer;
     1.7 -	int    i, done;
     1.8 +	int    i, k, done;
     1.9  	SDL_Event event;
    1.10  	SDL_Surface *light;
    1.11  	int mouse_pressed;
    1.12  	Uint32 ticks, lastticks;
    1.13 +	Uint16 *buffer16;
    1.14 +        Uint16 color;
    1.15 +        Uint8  gradient;
    1.16 +
    1.17  
    1.18  	/* Initialize SDL */
    1.19  	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    1.20 @@ -298,12 +302,17 @@
    1.21  		video_bpp = info->vfmt->BitsPerPixel;
    1.22  	} else {
    1.23  		video_bpp = 16;
    1.24 +                fprintf(stderr, "forced 16 bpp mode\n");
    1.25  	}
    1.26  	videoflags = SDL_SWSURFACE;
    1.27  	while ( argc > 1 ) {
    1.28  		--argc;
    1.29  		if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
    1.30  			video_bpp = atoi(argv[argc]);
    1.31 +                        if (video_bpp<=8) {
    1.32 +                            video_bpp=16;
    1.33 +                            fprintf(stderr, "forced 16 bpp mode\n");
    1.34 +                        }
    1.35  			--argc;
    1.36  		} else
    1.37  		if ( strcmp(argv[argc], "-hw") == 0 ) {
    1.38 @@ -336,10 +345,26 @@
    1.39  		exit(2);
    1.40  	}
    1.41  	buffer=(Uint8 *)screen->pixels;
    1.42 -	for ( i=0; i<screen->h; ++i ) {
    1.43 -		memset(buffer,(i*255)/screen->h, screen->pitch);
    1.44 -		buffer += screen->pitch;
    1.45 +	if (screen->format->BytesPerPixel!=2) {
    1.46 +		for ( i=0; i<screen->h; ++i ) {
    1.47 +			memset(buffer,(i*255)/screen->h, screen->pitch);
    1.48 +			buffer += screen->pitch;
    1.49 +		}
    1.50  	}
    1.51 +        else
    1.52 +        {
    1.53 +		for ( i=0; i<screen->h; ++i ) {
    1.54 +			gradient=((i*255)/screen->h);
    1.55 +                        color = SDL_MapRGB(screen->format, gradient, gradient, gradient);
    1.56 +                        buffer16=(Uint16*)buffer;
    1.57 +                        for (k=0; k<screen->w; k++)
    1.58 +                        {
    1.59 +                            *(buffer16+k)=color;
    1.60 +                        }
    1.61 +			buffer += screen->pitch;
    1.62 +		}
    1.63 +        }
    1.64 +
    1.65  	SDL_UnlockSurface(screen);
    1.66  	SDL_UpdateRect(screen, 0, 0, 0, 0);
    1.67