comparison 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
comparison
equal deleted inserted replaced
4798:980614a70cfc 4799:a0e096916474
61 Uint8 r = 0,g = 0,b = 0,alpha = 0; 61 Uint8 r = 0,g = 0,b = 0,alpha = 0;
62 Uint8* pixel; 62 Uint8* pixel;
63 Uint32 bitmap_pixel; 63 Uint32 bitmap_pixel;
64 if(SDL_MUSTLOCK(shape)) 64 if(SDL_MUSTLOCK(shape))
65 SDL_LockSurface(shape); 65 SDL_LockSurface(shape);
66 for(x = 0;x<shape->w;x++) 66 pixel = (Uint8*)shape->pixels;
67 for(y = 0;y<shape->h;y++) { 67 for(y = 0;y<shape->h;y++) {
68 pixel = (Uint8 *)(shape->pixels) + (y*shape->pitch) + (x*shape->format->BytesPerPixel); 68 pixel = (Uint8 *)(shape->pixels) + y * shape->pitch;
69 for(x=0;x<shape->w;x++) {
69 alpha = 0; 70 alpha = 0;
70 SDL_GetRGBA(*(Uint32*)pixel,shape->format,&r,&g,&b,&alpha); 71 SDL_GetRGBA(*(Uint32*)pixel,shape->format,&r,&g,&b,&alpha);
71 bitmap_pixel = y*shape->w + x; 72 bitmap_pixel = y*shape->w + x;
72 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); 73 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb));
74 pixel += shape->format->BytesPerPixel;
73 } 75 }
76 }
74 if(SDL_MUSTLOCK(shape)) 77 if(SDL_MUSTLOCK(shape))
75 SDL_UnlockSurface(shape); 78 SDL_UnlockSurface(shape);
76 } 79 }
77 80
78 int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { 81 int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {