某家贴上程序吧
有BUG通知我,谢谢)
---------------------
<font color=blue>窗体文件</font>
object Form1: TForm1
Left = 288
Top = 159
Width = 462
Height = 404
Caption = 'Form1'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -18
Font.Name = '宋体'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 120
TextHeight = 18
object Panel2: TPanel
Left = 0
Top = 0
Width = 454
Height = 30
Align = alTop
TabOrder = 0
object SpeedButton1: TSpeedButton
Left = 4
Top = 3
Width = 26
Height = 24
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000074120000741200001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
3333330000003300333333333333330000003301003333333333330000003301
9100333333333300000033019991003333333300000033019999910033333300
0000330199999991003333000000330199999999910033000000330199999999
9991030000003301999999999991030000003301999999999100330000003301
9999999100333300000033019999910033333300000033019991003333333300
0000330191003333333333000000330100333333333333000000330033333333
333333000000333333333333333333000000}
OnClick = SpeedButton1Click
end
object SpeedButton2: TSpeedButton
Left = 32
Top = 3
Width = 25
Height = 24
Caption = '抓'
OnClick = SpeedButton2Click
end
object SpeedButton3: TSpeedButton
Left = 60
Top = 3
Width = 25
Height = 24
Caption = '录'
end
object SpeedButton4: TSpeedButton
Left = 87
Top = 3
Width = 26
Height = 24
Caption = '源'
OnClick = SpeedButton4Click
end
object SpeedButton5: TSpeedButton
Left = 116
Top = 3
Width = 25
Height = 24
Hint = '亮度饱和度'
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000074120000741200001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF
FFFFFF000000FFFFFFF00000000FFF000000FFFFFF0CCCCCCCC0FF000000FFFF
F0CCFCCCCCCC0F000000FFFFF0CCCFCCCCCC0F000000FFFFF80CCFCCCCC0FF00
0000FFF0770CCFCCCCC0FF000000FF07BB0CCFCCCCC0FF000000F07BBBB0CFCC
CC0FFF000000F7BBBFF0CCCCCC0FFF00000007BBFFF0FFF7FF0FFF00000007BB
FFF0FBF7FF0FFF00000007BFFFFF0BF7F0FFFF000000F7BBFFFF000000FFFF00
0000F07BBFFFBB78FFFFFF000000FF07BBBBB70FFFFFFF000000FFF0777770FF
FFFFFF000000FFFFF000FFFFFFFFFF000000}
ParentShowHint = False
ShowHint = True
OnClick = SpeedButton5Click
end
object SpeedButton6: TSpeedButton
Left = 144
Top = 3
Width = 24
Height = 24
Hint = '对比度,色调'
Glyph.Data = {
4E010000424D4E01000000000000760000002800000012000000120000000100
040000000000D800000074120000741200001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF
FFFFFF000000F0000000FF0000000F000000FF999999001111110F000000F044
44440FCCCCCCFF000000FF9999990FCCCCCCFF000000F04444440FCCCCCCFF00
0000F04444440F1111110F000000FF9999990F1111110F000000FF9999990F11
11110F000000F044444400CCCCCCFF000000F0444444F0CCCCCCFF000000F044
4444F01111110F000000FF999999F01111110F000000FF999999F0CCCCCCFF00
0000FF999999F01111110F000000F044444400CCCCCCFF000000F0000000FF00
00000F000000FFFFFFFFFFFFFFFFFF000000}
ParentShowHint = False
ShowHint = True
OnClick = SpeedButton6Click
end
object sp_8_24: TSpeedButton
Left = 172
Top = 3
Width = 25
Height = 24
ParentShowHint = False
ShowHint = True
OnClick = sp_8_24Click
end
end
object Panel1: TPanel
Left = 0
Top = 30
Width = 454
Height = 322
Align = alClient
BevelInner = bvLowered
Color = clWindowFrame
TabOrder = 1
object Image1: TImage
Left = 2
Top = 2
Width = 450
Height = 318
Align = alClient
Stretch = True
Visible = False
end
object Image2: TImage
Left = 2
Top = 2
Width = 450
Height = 318
Align = alClient
Stretch = True
Visible = False
end
end
object StatusBar1: TStatusBar
Left = 0
Top = 352
Width = 454
Height = 19
Panels = <>
SimplePanel = False
end
object Timer1: TTimer
Enabled = False
Interval = 100
OnTimer = Timer1Timer
Left = 400
end
object SavePictureDialog1: TSavePictureDialog
Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing]
Left = 256
end
end
//////////////////////////////////////////////////
<font color=blue>单元文件</font>
unit Unit_mci;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, ExtCtrls, MPlayer, mmsystem, ComCtrls, Clipbrd, Buttons,
ExtDlgs;
type
TForm1 = class(TForm)
Panel2: TPanel;
Panel1: TPanel;
StatusBar1: TStatusBar;
Image1: TImage;
SpeedButton1: TSpeedButton;
Timer1: TTimer;
Image2: TImage;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
sp_8_24: TSpeedButton;
SavePictureDialog1: TSavePictureDialog;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure sp_8_24Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
cat_sp_24_8:boolean;
{ Private declarations }
public
procedure mci_SendString(command_str
char);
function PlayAviWindow(x_image_1,x_image_2:Timage):boolean;
procedure VideoLoad;
{ Public declarations }
end;
var
Form1: TForm1;
{$R cat_capture.res} //引用资源文件
implementation
uses Unit_mci_source, Unit_mci_change;
{$R *.DFM}
//-----------.* * 自定义函数/过程 * *.-------------------------
// *
// * 过程:mci_SendString(command_str
char)
// * 功能:封装 API -> MciSendString(...)
//API 原形(在 mmsystem.pas 中):
//function mciSendString(lpstrCommand, lpstrReturnString: PChar;
// uReturnLength: UINT; hWndCallback: HWND): MCIERROR; stdcall;
//function mciGetErrorString(mcierr: MCIERROR; pszText: PChar; uLength: UINT): BOOL; stdcall;
//function mciExecute(pszCommand: LPCSTR): BOOL; stdcall;
procedure TForm1.mci_SendString(command_str
char);
var
ret : Longint;
tstr : array[0..200] of char;
begin
ret := mciSendString(command_str,nil,0,0); // ?form1
If not(ret=0) Then
begin
mciGetErrorString(ret,tstr,200); //
end;
end;
function TForm1.PlayAviWindow(x_image_1,x_image_2:Timage):boolean; //自定义
begin
result := false;
StatusBar1.SimpleText := '播放视频……';
//
mci_sendstring('copy cat_mci'); //300x200
if Clipboard.HasFormat(CF_BITMAP)=true then
begin
if x_image_1.Visible=false then
begin
x_image_1.Picture.Assign(Clipboard);
x_image_2.Visible := false;
x_image_1.Visible := true;
end else begin
x_image_2.Picture.Assign(Clipboard);
x_image_1.Visible := false;
x_image_2.Visible := true;
end;
mci_SendString('unfreeze cat_mci');
//
result := true;
end;
end;
procedure TForm1.VideoLoad; //加载图象时初始化图象性质
begin
mci_Sendstring('freeze cat_Mci');
mci_SendString('SetVideo cat_mci bitsperpel to 24');
mci_Sendstring('unfreeze cat_Mci');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_24_8');
sp_8_24.Hint := '转换成黑白图象';
end;
//==================================================
procedure TForm1.FormCreate(Sender: TObject);
begin
speedbutton2.Enabled := false;
speedbutton3.Enabled := false;
speedbutton4.Enabled := false;
speedbutton5.Enabled := false;
speedbutton6.Enabled := false;
sp_8_24.Enabled := false;
//
cat_sp_24_8 :=false;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mci_SendString('close cat_mci');
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
mci_SendString('open overlay alias cat_mci');
VideoLoad;
timer1.enabled := true;
//
speedbutton2.Enabled := true;
speedbutton3.Enabled := true;
speedbutton4.Enabled := true;
speedbutton5.Enabled := true;
speedbutton6.Enabled := true;
sp_8_24.Enabled := true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if PlayAviWindow(image1,image2)=false then
application.MessageBox('播放视频失败。','MCI 设备',mb_ok+mb_iconStop);
end;
procedure TForm1.sp_8_24Click(Sender: TObject); // -- ok --
begin
mci_SendString('freeze cat_mci');
if cat_sp_24_8=false then
begin
mci_SendString('SetVideo cat_mci bitsperpel to 8');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_8_24');
cat_sp_24_8 := true;
sp_8_24.Hint := '转换成彩色图象';
end else begin
mci_SendString('SetVideo cat_mci bitsperpel to 24');
sp_8_24.Glyph.Handle := LoadBitmap(HInstance,'A_24_8');
cat_sp_24_8 := false;
sp_8_24.Hint := '转换成黑白图象';
end;
mci_SendString('unfreeze cat_mci');
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
savePictureDialog1.Filter := '*.BMP|*.bmp+*.JPG|*.jpg';
savePictureDialog1.DefaultExt := 'BMP';
if SavePictureDialog1.Execute=true then
if image1.Visible=true then
image1.Picture.SaveToFile(SavePictureDialog1.filename)//'aa.bmp')
else
image2.Picture.SaveToFile(SavePictureDialog1.filename);//'aa.bmp');
end;
procedure TForm1.SpeedButton5Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
reg01:TRegistry;
begin
form_change.Caption := '调节亮度和饱和度';
//
if form_change.ShowModal=mrok then
begin
mci_sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci brightness to ');
aa1 := aa1+form_change.Edit1.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
aa1 := strpas('setvideo cat_mci color to ');
aa1 := aa1+form_change.Edit2.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;
procedure TForm1.SpeedButton6Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
reg02:Tregistry;
begin
form_change.Caption := '调节对比度和色调值';
//
if form_change.ShowModal=mrok then
begin
mci_Sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci contrast to ');
aa1 := aa1+form_change.Edit1.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
aa1 := strpas('setvideo cat_mci tint to ');
aa1 := aa1+form_change.Edit2.text;
strpcopy(aa2,aa1);
mci_SendString(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;
procedure TForm1.SpeedButton4Click(Sender: TObject);
var
aa1:string;
aa2:array[0..127] of char;
begin
if form_source.ShowModal=mrok then
begin
mci_Sendstring('freeze cat_mci');
//
aa1 := strpas('setvideo cat_mci number ')+form_source.aa;
strpcopy(aa2,aa1);
mci_Sendstring(aa2);
//
mci_Sendstring('unfreeze cat_mci');
end;
end;
end.