diff src/video/SDL_shape.c @ 4799:a0e096916474

Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
author Eli Gottlieb <eligottlieb@gmail.com>
date Sun, 18 Jul 2010 21:31:22 -0400
parents e8caf178d082
children 506a9165491b
line wrap: on
line diff
--- a/src/video/SDL_shape.c	Sun Jul 18 15:15:05 2010 -0400
+++ b/src/video/SDL_shape.c	Sun Jul 18 21:31:22 2010 -0400
@@ -63,14 +63,17 @@
 	Uint32 bitmap_pixel;
 	if(SDL_MUSTLOCK(shape))
 		SDL_LockSurface(shape);
-	for(x = 0;x<shape->w;x++)
-		for(y = 0;y<shape->h;y++) {
-			pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel);
+	pixel = (Uint8*)shape->pixels;
+	for(y = 0;y<shape->h;y++) {
+		pixel = (Uint8 *)(shape->pixels) + y * shape->pitch;
+		for(x=0;x<shape->w;x++) {
 			alpha = 0;
 			SDL_GetRGBA(*(Uint32*)pixel,shape->format,&r,&g,&b,&alpha);
 			bitmap_pixel = y*shape->w + x;
 			bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb));
+			pixel += shape->format->BytesPerPixel;
 		}
+	}
 	if(SDL_MUSTLOCK(shape))
 		SDL_UnlockSurface(shape);
 }