+void
+apply_filter_to_surface(SDL_Surface* surface, int filter, Color color)
+{
+if(filter == MASK_FILTER)
+ {
+ SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true);
+
+ Uint8 r,g,b,a;
+
+ SDL_LockSurface(sur_copy);
+ for(int x = 0; x < sur_copy->w; x++)
+ for(int y = 0; y < sur_copy->h; y++)
+ {
+ SDL_GetRGBA(getpixel(sur_copy,x,y), sur_copy->format, &r,&g,&b,&a);
+ if(a != 0)
+ {
+ putpixel(sur_copy, x,y, color.map_rgba(sur_copy));
+ }
+ }
+ SDL_UnlockSurface(sur_copy);
+
+ SDL_BlitSurface(sur_copy, NULL, surface, NULL);
+ SDL_FreeSurface(sur_copy);
+ }
+}
+