(20111216) 01:00

This commit is contained in:
2011-12-16 01:00:00 +01:00
parent 0855d72749
commit f67911db62
16 changed files with 367 additions and 97 deletions

39
Draw.c
View File

@@ -178,8 +178,25 @@ DrawImg Draw_LoadImage(char *filename){
// FIX: Setting up the alpha channel.
if(surf->format->BytesPerPixel==4){
int i,len,trans;
// set the correct values
surf->format->Amask=0xFF000000;
surf->format->Ashift=24;
// Check if the image has some area transparent
trans=0;
len=surf->w*surf->h;
for(i=0;i<len;i++){
if((((Uint32 *)surf->pixels)[i]&0xFF000000)!=0xFF000000){
trans=1;
break;
}
}
if(trans){
// Make it use the alpha channel
SDL_SetAlpha(surf, SDL_SRCALPHA, 255);
}
}
// Create the image container
@@ -277,6 +294,28 @@ void Draw_DrawImg(DrawImg img,int x,int y){
}
/////////////////////////////
// Draw_DrawImgPart
//
// Draws an image part.
void Draw_DrawImgPart(DrawImg img,int x,int y,int w,int i){
DrawImage *image=img;
SDL_Rect orig;
SDL_Rect dest;
// Prepare the rects
orig.x=w*i;
orig.y=0;
dest.x=x+image->x;
dest.y=y+image->y;
orig.w=dest.w=w;
orig.h=dest.h=image->surf->h;
// Blit the surface on the screen
SDL_BlitSurface(image->surf,&orig,_screen,&dest);
}
////////////////////////////////////////////////
// DrawFnt //
/////////////