[SDL] Sorry to bother you

mads jørgensen madsj_6 at hotmail.com
Sat Dec 22 17:21:07 PST 2007


I usually does not use it. it seems i got the tempframe to display correct on the screen. It seems if i do the following:SDL_Surface* tempframe1 = SDL_CreateRGBSurface( SDL_SWSURFACE,                                               genseframes[frame1].w,                                              genseframes[frame1].h,                                               32,0,0,0,0);                                                          SDL_SetColorKey(tempframe1, SDL_SRCCOLORKEY , SDL_MapRGB(tempframe1->format, 255, 0, 255));         SDL_Surface* tempframe =SDL_DisplayFormatAlpha( tempframe1 );          SDL_FreeSurface(tempframe1);                      SDL_SetAlpha(tempframe,NULL,0);          SDL_FillRect(tempframe, NULL,SDL_MapRGB(tempframe->format, 255, 0, 255));             apply_surface(0,0,tempframe,screen);               apply_surface(0,0,gense,tempframe,&genseframes[frame1]);    temp1 = rotozoomSurface(tempframe,rotation1*(-180/b2_pi),1,0); if i put colorkey before displayformatalpha() then the colorkey isn't being used by tempframe1/tempframe. However if i put it after, it is. However, anyway i end up with the pink rectangles around my grey sprites both ways...If i have colorkey after displayformatalpha(), apply_surface(0,0,tempframe,screen); draws nothing in the upper left corner, however putting colorkey before, it draws the pink rectangle in the upper left corner.this is the function im currently using for loading from memory:SDL_Surface *load_image( string filename )     {        //The image that's loaded        SDL_Surface* loadedImage = NULL;                //The optimized surface that will be used        SDL_Surface* optimizedImage = NULL;                //Load the image        loadedImage = IMG_Load( filename.c_str() );                //If the image loaded        if( loadedImage != NULL )                    {          SDL_SetColorKey( loadedImage, SDL_SRCCOLORKEY, SDL_MapRGB( loadedImage->format, 255, 0, 255 ) );            //Create an optimized surface            optimizedImage = SDL_DisplayFormatAlpha( loadedImage );                            //Free the old surface            SDL_FreeSurface( loadedImage );                                           }        //Return the optimized surface        return optimizedImage;    }


From: grimfang4 at hotmail.comTo: sdl at lists.libsdl.orgDate: Sat, 22 Dec 2007 19:48:20 -0500Subject: Re: [SDL] Sorry to bother you



Hey,Does colorkeying definitely work with SDL_SRCALPHA?Jonny D


From: madsj_6 at hotmail.comTo: sdl at lists.libsdl.orgDate: Sat, 22 Dec 2007 13:48:33 +0000Subject: [SDL] Sorry to bother you

Hello. I have a very stupid problem. I have tried for several days to get it working, but i can't seem to get it right.I am actually trying to do the simple thing to make a empty surface, and then draw another image into it. My code is the following (c++)://code for drawing from one surface to another:void apply_surface( float x, float y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL )	{		//Holds offsets		SDL_Rect offset;	    		//Get offsets		offset.x = x;		offset.y = y;				   		//Blit		SDL_BlitSurface( source, clip, destination, &offset );	}//code for loading an image from memory:SDL_Surface *load_image( string filename ) 	{		//The image that's loaded		SDL_Surface* loadedImage = NULL;	    		//The optimized surface that will be used		SDL_Surface* optimizedImage = NULL;	    		//Load the image		loadedImage = IMG_Load( filename.c_str() );	    		//If the image loaded		if( loadedImage != NULL )					{		  SDL_SetColorKey( loadedImage, SDL_SRCCOLORKEY, SDL_MapRGB( loadedImage->format, 255, 0, 255 ) );			//Create an optimized surface			optimizedImage = SDL_DisplayFormatAlpha( loadedImage );	        			//Free the old surface			SDL_FreeSurface( loadedImage );	        	       	        		}		//Return the optimized surface		return optimizedImage;	}//the code for making the empty surface(tempframe) and applying the appropriate sprite from the sprite sheet// loaded from memory://create an empty surfaceSDL_Surface* tempframe = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA,                                               genseframes[frame1].w,                                              genseframes[frame1].h,                                               32,                                               gense->format->Rmask,                                            gense->format->Gmask,                                gense->format->Bmask,                             gense->format->Amask);//fill it with the colorkey color       SDL_FillRect(tempframe, NULL,SDL_MapRGB(tempframe->format, 255, 0, 255));//assaign the colorkey                                SDL_SetColorKey(tempframe, SDL_SRCCOLORKEY , SDL_MapRGB(tempframe->format, 255, 0, 255))   ;//draw the current frame from the gense spritesheet  apply_surface(0,0,gense,tempframe,&genseframes[frame1]);/////////////////////////////the result is the following (look at the sprite on the left with the pink rectangle around it, it is supposed to be completely transparent)http://img297.imageshack.us/my.php?image=notdrawingqv8.jpgThanks for your time,Mads

Kombiner det bedste fra Windows og nettet med Windows Live Hent det nu! 

i’m is proud to present Cause Effect, a series about real people making a difference. Learn more 
_________________________________________________________________
Få styr på dine billeder gratis med Windows Live Billedgalleri
www.windowslive.dk/billedgalleri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20071223/81ceecb7/attachment-0008.htm>


More information about the SDL mailing list