ColorControl.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:4k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit ColorControl;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  5.   Dialogs, Buttons, StdCtrls, ComCtrls, ExtCtrls;
  6. type
  7.   TColorControlForm = class(TForm)
  8.     Shape1: TShape;
  9.     Label1: TLabel;
  10.     TrackBar1: TTrackBar;
  11.     Label2: TLabel;
  12.     TrackBar2: TTrackBar;
  13.     Label3: TLabel;
  14.     TrackBar3: TTrackBar;
  15.     Label4: TLabel;
  16.     TrackBar4: TTrackBar;
  17.     CheckBox1: TCheckBox;
  18.     SpeedButton1: TSpeedButton;
  19.     procedure FormDeactivate(Sender: TObject);
  20.     procedure FormShow(Sender: TObject);
  21.     procedure Button1Click(Sender: TObject);
  22.     procedure TrackBar1Change(Sender: TObject);
  23.     procedure TrackBar2Change(Sender: TObject);
  24.     procedure TrackBar3Change(Sender: TObject);
  25.     procedure TrackBar4Change(Sender: TObject);
  26.     procedure CheckBox1Click(Sender: TObject);
  27.     procedure SpeedButton1Click(Sender: TObject);
  28.     procedure GetValues;
  29.   private
  30.     { Private declarations }
  31.   public
  32.     { Public declarations }
  33.   end;
  34. var
  35.   ColorControlForm: TColorControlForm;
  36. implementation
  37. uses Unit1;
  38. {$R *.dfm}
  39. procedure TColorControlForm.FormDeactivate(Sender: TObject);
  40. begin
  41.   Close;
  42. end;
  43. procedure TColorControlForm.FormShow(Sender: TObject);
  44. begin
  45.   Color := Form1.DSVideoWindowEx1.ColorKey;
  46.   Shape1.Brush.Color := Form1.DSVideoWindowEx1.ColorKey;
  47.   Left := Form1.DSVideoWindowEx1.ClientOrigin.X + (Form1.DSVideoWindowEx1.Width div 2) - (Width div 2);
  48.   Top := Form1.DSVideoWindowEx1.ClientOrigin.Y + (Form1.DSVideoWindowEx1.Height div 2) - (Height div 2);
  49.   Trackbar1.Enabled := Form1.DSVideoWindowEx1.Capabilities.CanControlBrigtness;
  50.   Trackbar1.SliderVisible := Form1.DSVideoWindowEx1.Capabilities.CanControlBrigtness;
  51.   Trackbar2.Enabled := Form1.DSVideoWindowEx1.Capabilities.CanControlContrast;
  52.   Trackbar2.SliderVisible := Form1.DSVideoWindowEx1.Capabilities.CanControlContrast;
  53.   Trackbar3.Enabled := Form1.DSVideoWindowEx1.Capabilities.CanControlHue;
  54.   Trackbar3.SliderVisible := Form1.DSVideoWindowEx1.Capabilities.CanControlHue;
  55.   Trackbar4.Enabled := Form1.DSVideoWindowEx1.Capabilities.CanControlSaturation;
  56.   Trackbar4.SliderVisible := Form1.DSVideoWindowEx1.Capabilities.CanControlSaturation;
  57.   CheckBox1.Enabled := Form1.DSVideoWindowEx1.Capabilities.CanControlColorEnabled;
  58.   GetValues;
  59. end;
  60. procedure TColorControlForm.Button1Click(Sender: TObject);
  61. begin
  62.   Form1.DSVideoWindowEx1.ColorControl.RestoreDefault;
  63. end;
  64. procedure TColorControlForm.TrackBar1Change(Sender: TObject);
  65. begin
  66.   Form1.DSVideoWindowEx1.ColorControl.Brightness := TrackBar1.Position;
  67. end;
  68. procedure TColorControlForm.TrackBar2Change(Sender: TObject);
  69. begin
  70.   Form1.DSVideoWindowEx1.ColorControl.Contrast := TrackBar2.Position;
  71. end;
  72. procedure TColorControlForm.TrackBar3Change(Sender: TObject);
  73. begin
  74.   Form1.DSVideoWindowEx1.ColorControl.Hue := TrackBar3.Position;
  75. end;
  76. procedure TColorControlForm.TrackBar4Change(Sender: TObject);
  77. begin
  78.   Form1.DSVideoWindowEx1.ColorControl.Saturation := TrackBar4.Position;
  79. end;
  80. procedure TColorControlForm.CheckBox1Click(Sender: TObject);
  81. begin
  82.   Form1.DSVideoWindowEx1.ColorControl.ColorEnable := CheckBox1.Checked;
  83. end;
  84. procedure TColorControlForm.SpeedButton1Click(Sender: TObject);
  85. begin
  86.   Form1.DSVideoWindowEx1.ColorControl.RestoreDefault;
  87.   GetValues;
  88. end;
  89. procedure TColorControlForm.GetValues;
  90. Begin
  91.   CheckBox1.Checked := Form1.DSVideoWindowEx1.ColorControl.ColorEnable;
  92.   TrackBar4.Position := Form1.DSVideoWindowEx1.ColorControl.Saturation;
  93.   TrackBar3.Position := Form1.DSVideoWindowEx1.ColorControl.Hue;
  94.   TrackBar2.Position := Form1.DSVideoWindowEx1.ColorControl.Contrast;
  95.   TrackBar1.Position := Form1.DSVideoWindowEx1.ColorControl.Brightness;
  96. End;
  97. end.