<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
I usually does not use it. it seems i got the tempframe to display correct on the screen. <BR>It seems if i do the following:<BR><BR>SDL_Surface* tempframe1 = SDL_CreateRGBSurface( SDL_SWSURFACE,<BR>                                               genseframes[frame1].w,<BR>                                              genseframes[frame1].h,<BR>                                               32,0,0,0,0);<BR>                                              <BR>            SDL_SetColorKey(tempframe1, SDL_SRCCOLORKEY , SDL_MapRGB(tempframe1->format, 255, 0, 255));<BR>         SDL_Surface* tempframe =SDL_DisplayFormatAlpha( tempframe1 );<BR>          SDL_FreeSurface(tempframe1);              <BR>  <BR>      SDL_SetAlpha(tempframe,NULL,0);<BR>      <BR>    SDL_FillRect(tempframe, NULL,SDL_MapRGB(tempframe->format, 255, 0, 255));<BR>       <BR>      apply_surface(0,0,tempframe,screen); <BR>       <BR>       apply_surface(0,0,gense,tempframe,&genseframes[frame1]);<BR>    temp1 = rotozoomSurface(tempframe,rotation1*(-180/b2_pi),1,0); <BR><BR>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...<BR>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.<BR><BR>this is the function im currently using for loading from memory:<BR><BR>SDL_Surface *load_image( string filename ) <BR>    {<BR>        //The image that's loaded<BR>        SDL_Surface* loadedImage = NULL;<BR>        <BR>        //The optimized surface that will be used<BR>        SDL_Surface* optimizedImage = NULL;<BR>        <BR>        //Load the image<BR>        loadedImage = IMG_Load( filename.c_str() );<BR>        <BR>        //If the image loaded<BR>        if( loadedImage != NULL )            <BR>        {<BR>          SDL_SetColorKey( loadedImage, SDL_SRCCOLORKEY, SDL_MapRGB( loadedImage->format, 255, 0, 255 ) );<BR>            //Create an optimized surface<BR>            optimizedImage = SDL_DisplayFormatAlpha( loadedImage );<BR>                <BR>            //Free the old surface<BR>            SDL_FreeSurface( loadedImage );<BR>            <BR>           <BR>            <BR>        }<BR>        //Return the optimized surface<BR>        return optimizedImage;<BR>    }<BR><BR>
<BLOCKQUOTE>
<HR>
From: grimfang4@hotmail.com<BR>To: sdl@lists.libsdl.org<BR>Date: Sat, 22 Dec 2007 19:48:20 -0500<BR>Subject: Re: [SDL] Sorry to bother you<BR><BR>
<META content="Microsoft SafeHTML" name=Generator>
<STYLE>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass EC_body.hmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>

<DIV style="TEXT-ALIGN: left">Hey,<BR><BR>Does colorkeying definitely work with SDL_SRCALPHA?<BR><BR>Jonny D<BR></DIV><BR><BR><BR>
<BLOCKQUOTE>
<HR id=EC_EC_stopSpelling>
From: madsj_6@hotmail.com<BR>To: sdl@lists.libsdl.org<BR>Date: Sat, 22 Dec 2007 13:48:33 +0000<BR>Subject: [SDL] Sorry to bother you<BR><BR>
<STYLE>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass EC_body.hmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
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.<BR>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++):<BR><BR>//code for drawing from one surface to another:<BR><BR><PRE><SPAN class=EC_EC_cpp-keyword>void</SPAN> apply_surface( <SPAN class=EC_EC_cpp-keyword>float</SPAN> x, <SPAN class=EC_EC_cpp-keyword>float</SPAN> y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL )<BR>   {<BR>             <SPAN class=EC_EC_cpp-comment>//Holds offsets</SPAN><BR>              SDL_Rect offset;<BR>          <BR>          <SPAN class=EC_EC_cpp-comment>//Get offsets</SPAN><BR>                offset.x = x;<BR>         offset.y = y;<BR>         <BR>                 <BR>           <SPAN class=EC_EC_cpp-comment>//Blit</SPAN><BR>               SDL_BlitSurface( source, clip, destination, &offset );<BR>    }<BR><BR>//code for loading an image from memory:<BR>SDL_Surface *load_image( string filename ) <BR>    {<BR>             <SPAN class=EC_EC_cpp-comment>//The image that's loaded</SPAN><BR>            SDL_Surface* loadedImage = NULL;<BR>          <BR>          <SPAN class=EC_EC_cpp-comment>//The optimized surface that will be used</SPAN><BR>            SDL_Surface* optimizedImage = NULL;<BR>       <BR>          <SPAN class=EC_EC_cpp-comment>//Load the image</SPAN><BR>             loadedImage = IMG_Load( filename.c_str() );<BR>       <BR>          <SPAN class=EC_EC_cpp-comment>//If the image loaded</SPAN><BR>                <SPAN class=EC_EC_cpp-keyword>if</SPAN>( loadedImage != NULL )                      <BR>              {<BR>               SDL_SetColorKey( loadedImage, SDL_SRCCOLORKEY, SDL_MapRGB( loadedImage->format, <SPAN class=EC_EC_cpp-number>255</SPAN>, <SPAN class=EC_EC_cpp-number>0</SPAN>, <SPAN class=EC_EC_cpp-number>255</SPAN> ) );<BR>                 <SPAN class=EC_EC_cpp-comment>//Create an optimized surface</SPAN><BR>                        optimizedImage = SDL_DisplayFormatAlpha( loadedImage );<BR>               <BR>                      <SPAN class=EC_EC_cpp-comment>//Free the old surface</SPAN><BR>                       SDL_FreeSurface( loadedImage );<BR>               <BR>             <BR>               <BR>              }<BR>             <SPAN class=EC_EC_cpp-comment>//Return the optimized surface</SPAN><BR>               <SPAN class=EC_EC_cpp-keyword>return</SPAN> optimizedImage;<BR>       }<BR><BR>//the code for making the empty surface(tempframe) and applying the appropriate sprite from the sprite sheet<BR>// loaded from memory:<BR><SPAN class=EC_EC_cpp-comment>//create an empty surface</SPAN><BR>SDL_Surface* tempframe = SDL_CreateRGBSurface( SDL_SWSURFACE|SDL_SRCALPHA,<BR>                                               genseframes[frame1].w,<BR>                                              genseframes[frame1].h,<BR>                                               <SPAN class=EC_EC_cpp-number>32</SPAN>,<BR>                                               gense->format->Rmask,<BR>                                            gense->format->Gmask,<BR>                                gense->format->Bmask,<BR>                             gense->format->Amask);<BR><SPAN class=EC_EC_cpp-comment>//fill it with the colorkey color       </SPAN><BR>SDL_FillRect(tempframe, NULL,SDL_MapRGB(tempframe->format, <SPAN class=EC_EC_cpp-number>255</SPAN>, <SPAN class=EC_EC_cpp-number>0</SPAN>, <SPAN class=EC_EC_cpp-number>255</SPAN>));<BR><BR><BR><BR><SPAN class=EC_EC_cpp-comment>//assaign the colorkey                                </SPAN><BR>SDL_SetColorKey(tempframe, SDL_SRCCOLORKEY , SDL_MapRGB(tempframe->format, <SPAN class=EC_EC_cpp-number>255</SPAN>, <SPAN class=EC_EC_cpp-number>0</SPAN>, <SPAN class=EC_EC_cpp-number>255</SPAN>))   ;<BR><SPAN class=EC_EC_cpp-comment>//draw the current frame from the gense spritesheet  </SPAN><BR>apply_surface(<SPAN class=EC_EC_cpp-number>0</SPAN>,<SPAN class=EC_EC_cpp-number>0</SPAN>,gense,tempframe,&genseframes[frame1]);<BR><BR></PRE>/////////////////////////////<BR>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)<BR>http://img297.imageshack.us/my.php?image=notdrawingqv8.jpg<BR><BR>Thanks for your time,<BR>Mads<BR><BR>
<HR>
Kombiner det bedste fra Windows og nettet med Windows Live <A href="http://www.windowslive.dk/suite" target=_blank>Hent det nu!</A> </BLOCKQUOTE><BR>
<HR>
iím is proud to present Cause Effect, a series about real people making a difference. <A href="http://im.live.com/Messenger/IM/MTV/?source=text_Cause_Effect" target=_blank>Learn more</A> </BLOCKQUOTE><br /><hr />Kombiner det bedste fra Windows og nettet med Windows Live <a href='www.windowslive.dk/suite' target='_new'>Hent det nu!</a></body>
</html>