home *** CD-ROM | disk | FTP | other *** search
- Program RGBPaletteGrayScale;
- {--------------------------------------------------------------}
- { This program is a demonstration of using the SetRGBPalette }
- { procedure. It will reset the 16 palette entrys to point to }
- { DACs 0 through 15. These DACs will then be reprogrammed to }
- { create 16 shades of gray. }
- {--------------------------------------------------------------}
-
- Uses Crt, Graph; { Link in necessary library units }
-
- Const
- PathToDrivers = ''; { Location of support file for BGI }
- CValueIncrement = 3; { Increment for Red, Green, Blue gun }
-
- Var
- GraphDriver,
- GraphMode : Integer; { Variables for graphics mode }
- Ch : Char; { Character to use for pausing }
- P : PaletteType; { Palette record for GetPallet proc }
- I : Word; { Loop counter variable. }
- ColorValue : Word; { Value used for Red, Green, Blue gun }
- Y1, Y2,
- YInc,
- MaxX,
- MaxY : Word; { Values used for creating bars }
-
- Begin
- GraphDriver := VGA; { Initialize graphics driver for VGA }
- GraphMode := VGAHi; { Initialize mode to VGAHi res mode }
- InitGraph( GraphDriver, GraphMode, PathToDrivers );
- ColorValue := 0; { Start with true black }
- For I := 0 to 15 Do { Point each palette entry to DAC I }
- SetPalette( I,I );
- For I := 0 to 15 Do { Create the gray scales }
- Begin
- SetRGBPalette( I,ColorValue,ColorValue,ColorValue );
- Inc( ColorValue, CValueIncrement );
- End;
- MaxY := GetMaxY; { Store Maximum X resolution }
- MaxX := GetMaxX; { Store Maximum Y resolution }
- YInc := MaxY Div 16; { Create YInc as 1/16 of Y resolution }
- Y1 := 0;
- Y2 := YInc; { Initialize values for BAR procedure }
- For I := 0 to 15 do { Create 16 bars on screen with our }
- Begin { new shades of gray }
- SetFillStyle( SolidFill, I );
- Bar( 0,Y1,MaxX,Y2 );
- Inc( Y1, YInc );
- Inc( Y2, YInc );
- End;
- Ch := Readkey; { Pause for screen viewing }
- CloseGraph; { Shut down graphics system }
- End.