Mercurial > sdl-ios-xcode
comparison src/video/SDL_shape.c @ 4795:6f0bc179771c
Numerous bug fixes that keep testeyes from crashing and dying.
author | Eli Gottlieb <eligottlieb@gmail.com> |
---|---|
date | Wed, 14 Jul 2010 00:49:28 -0400 |
parents | a6bc01875d20 |
children | e8caf178d082 |
comparison
equal
deleted
inserted
replaced
4794:e562160a873f | 4795:6f0bc179771c |
---|---|
46 | 46 |
47 /* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */ | 47 /* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */ |
48 void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb,Uint8 value) { | 48 void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb,Uint8 value) { |
49 int x = 0; | 49 int x = 0; |
50 int y = 0; | 50 int y = 0; |
51 Uint8 alpha = 0; | 51 Uint8 r = 0,g = 0,b = 0,alpha = 0; |
52 Uint8* pixel; | 52 Uint8* pixel; |
53 Uint32 bitmap_pixel; | 53 Uint32 bitmap_pixel; |
54 if(SDL_MUSTLOCK(shape)) | 54 if(SDL_MUSTLOCK(shape)) |
55 SDL_LockSurface(shape); | 55 SDL_LockSurface(shape); |
56 for(x = 0;x<shape->w;x++) | 56 for(x = 0;x<shape->w;x++) |
57 for(y = 0;y<shape->h;y++) { | 57 for(y = 0;y<shape->h;y++) { |
58 pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel); | 58 pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel); |
59 alpha = 0; | 59 alpha = 0; |
60 SDL_GetRGBA(*(Uint32*)pixel,shape->format,NULL,NULL,NULL,&alpha); | 60 SDL_GetRGBA(*(Uint32*)pixel,shape->format,&r,&g,&b,&alpha); |
61 Uint32 bitmap_pixel = y*shape->w + x; | 61 Uint32 bitmap_pixel = y*shape->w + x; |
62 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); | 62 bitmap[bitmap_pixel / ppb] |= (alpha >= alphacutoff ? value : 0) << ((ppb - 1) - (bitmap_pixel % ppb)); |
63 } | 63 } |
64 if(SDL_MUSTLOCK(shape)) | 64 if(SDL_MUSTLOCK(shape)) |
65 SDL_UnlockSurface(shape); | 65 SDL_UnlockSurface(shape); |