1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
AjustPanel: TPanel;
Label1: TLabel;
Label4: TLabel;
Label3: TLabel;
Label2: TLabel;
ContrBar: TTrackBar;
LumBar: TTrackBar;
ColorBar: TTrackBar;
GammaBar: TTrackBar;
BReset: TButton;
DbgLab: TLabel;
procedure FormCreate(Sender: TObject);
procedure BResetClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure ContrBarChange(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
private
FBitmap: TBitmap;
procedure UpdateView();
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Rc: TRect;
C: TCanvas;
begin
FBitmap := TBitmap.Create;
GetWindowRect(GetDesktopWindow, Rc) ;
FBitmap.Width := Rc.Right - Rc.Left;
FBitmap.Height := Rc.Bottom - Rc.Top;
C := TCanvas.Create;
C.Handle := GetDc(0);
FBitmap.Canvas.CopyRect(Rc, C, Rc);
C.Free;
end;
procedure TForm1.UpdateView;
var
Aj: TColorAdjustment;
begin
SetStretchBltMode(Canvas.Handle, HALFTONE);
GetColorAdjustment(Canvas.Handle, Aj);
Aj.caContrast := ContrBar.Position;
Aj.caBrightness := LumBar.Position;
Aj.caColorfulness := ColorBar.Position * 10;
Aj.caRedGamma := GammaBar.Position * 100;
Aj.caGreenGamma := Aj.caRedGamma;
Aj.caBlueGamma := Aj.caRedGamma;
SetColorAdjustment(Canvas.Handle,Aj);
with Canvas do
CopyRect(BoundsRect, FBitmap.Canvas, BoundsRect);
end;
procedure TForm1.BResetClick(Sender: TObject);
begin
ContrBar.Position:= 0;
LumBar.Position:= 0;
ColorBar.Position:= 0;
GammaBar.Position:= 100;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
UpdateView();
end;
procedure TForm1.ContrBarChange(Sender: TObject);
begin
UpdateView();
DbgLab.Caption := Format('lum:%d const:%d color:%d gam:%d',[
LumBar.Position,
ContrBar.Position,
ColorBar.Position,
GammaBar.Position
])
end;
procedure TForm1.FormResize(Sender: TObject);
begin
AjustPanel.SetBounds(
(Width - AjustPanel.Width) div 2,
(Height - AjustPanel.Height) div 2,
AjustPanel.Width,
AjustPanel.Height
);
end;
procedure TForm1.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
if Msg.CharCode = VK_ESCAPE then
begin
ModalResult := mrCancel;
Close;
end;
end;
end. |
Partager