Implementing Brightness/contrast Adjustment


Hitnrun

Member
Joined
Mar 1, 2008
Messages
427
Is there an easy way to implement brightness/contrast adjustment using SDL, without modifying all images? I saw the SDL_SetGamma function, but it does not seem to work, should it work in the gp2x sdl?
 
I needed a smooth fade in the current game Im writing. I used a black 320x240 bitmap (fade_mask) and did:
CODE
SDL_SetAlpha(fade_mask, SDL_SRCALPHA | SDL_RLEACCEL, fade_value );
apply_surface(0,0,fade_mask,screen);


Not terribly efficient but as the game isnt CPU intensive it works fine.
 
Unfathomable Depths said:
I needed a smooth fade in the current game Im writing. I used a black 320x240 bitmap (fade_mask) and did:
CODE
SDL_SetAlpha(fade_mask, SDL_SRCALPHA | SDL_RLEACCEL, fade_value );
apply_surface(0,0,fade_mask,screen);
Not terribly efficient but as the game isnt CPU intensive it works fine.


Hmm but this just "lower" the brightness no? Can it be used to increase it too?
 
Last edited by a moderator:
This must be the confessional;
CODE

void fadetoblack( SDL_Surface * Surface )
{
short i, x;

for ( i = 0; i < 255; i+= i < 96 ? 2 : 64 )
{
x = boxRGBA( Surface, 0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0, 0, i );
SDL_Flip( Surface );
SDL_Delay(timeleft( 83 )); // 1/18 = 55 1/12 = 83
}
return;
}
 
The xRick port tweaked by JyCet has a nice gamma function that has a global effect, perhaps that is exactly what you need. Speaking of which, must play xRick :D

PS: got to love 8bit palette mode and its virtually free fades :)
 
Back
Top