Blitz3D Docs -> 2D - Category -> Graphics -> SetGamma
SetGamma red,green,blue,dest_red#,dest_green#,dest_blue#
Parameters:
red,green,blue - specifies the source red,green,blue components.dest_red#,dest_green#,dest_blue - specifies the destination red,green,blue components.
Description:
SetGamma allows you to modify the gamma tables.Gamma can ONLY be used in fullscreen mode.
After performing one or more SetGamma commands, you must call UpdateGamma in order for the changes to become effective.
Note that the behaviour of this command in Blitz3D is different to BlitzPlus. Blitz3D will clamp out of range values, so that 300 is treated as 255. BlitzPlus allows values to "roll-over", so that 300 is treated as 44.
See also: UpdateGamma.
Example:
;gamma demo - use left/right arrows to ;control display intensity ; ;hold down left-control for a 'red-out' effect! Graphics 640,480,16,1 SetBuffer BackBuffer() n=0 While Not KeyHit(1) If KeyDown(203) And n>0 Then n=n-1 If KeyDown(205) And n<255 Then n=n+1 If KeyDown(29) SetGammaRed(n) Else SetGammaIntensity(n) EndIf Cls SeedRnd 1234 For k=1 To 1000 Color Rnd(255),Rnd(255),Rnd(255) Rect Rnd(640),Rnd(480),Rnd(64),Rnd(64) Next Text 0,0,"Intensity offset="+n Flip Wend End ; bye! Function SetGammaRed( n ) For k=0 To 255 SetGamma k,k,k,k+n,0,0 Next UpdateGamma End Function Function SetGammaIntensity( n ) For k=0 To 255 SetGamma k,k,k,k+n,k+n,k+n Next UpdateGamma End Function
Comments
| ||
A little better Gamma function:
; Use wheel to change gamma
; Left mouse button for "red-out" effect
path$ = RequestFile("Select an image...")
Graphics 800, 600, 32, 1
image = LoadImage(path$)
MaskImage image, 255, 0, 255
While Not KeyHit(1)
g = g + MouseZSpeed()
tim% = Gamma(g, g * (1 - MouseDown(1)), g * (1 - MouseDown(1)))
Cls
DrawImage image, MouseX(), MouseY()
Color 200, 200, 200
Text 10, 10, "Gamma: " + g
Text 10, 30, "Gamma delay: " + tim%
Flip
Wend
End
Function Gamma(r%, g%, b%, calibrate% = False)
Local start% = MilliSecs()
For k% = 0 To 255
If k% + r% > 255 Then rl% = 255 - k% Else rl% = r%
If k% + g% > 255 Then gl% = 255 - k% Else gl% = g%
If k% + b% > 255 Then bl% = 255 - k% Else bl% = b%
SetGamma k%, k%, k%, k% + rl%, k% + gl%, k% + bl%
Next
UpdateGamma calibrate%
Return (MilliSecs() - start%)
End Function
|
| ||
| Andres - A little better Gamma function: "Function 'requestfile' not found" |
Blitz3D Manual Forum
BlitzPlus Equivalent Command




