一直接发是什么意思?
你要求什么样的>?
抓屏然后发送?
抓屏部分
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, TrayIcon, ExtCtrls, AppEvnts, IdTCPServer,
StdCtrls,jpeg;
const
READY='00000';
FASONG='11111';
ZHUNBEI='22222';
type
TForm1 = class(TForm)
TrayIcon1: TTrayIcon;
IdAntiFreeze1: TIdAntiFreeze;
Image1: TImage;
ApplicationEvents1: TApplicationEvents;
s: TIdTCPServer;
Edit1: TEdit;
c: TIdTCPClient;
procedure FormCreate(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure sExecute(AThread: TIdPeerThread);
private
{ Private declarations }
public
{ Public declarations }
procedure BMPToJPG(BmpFileName:string);
end;
var
Form1: TForm1;
m:TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
s.Active :=true;
form1.WindowState:=wsMinimized;
end;
procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
TRAYICON1.Visible :=true;
end;
procedure TForm1.ApplicationEvents1Restore(Sender: TObject);
begin
trayicon1.Visible :=false;
end;
procedure TForm1.sExecute(AThread: TIdPeerThread);
var
Temp:String;
Fullscreen : TBitmap;
FullscreenCanvas : TCanvas;
DC : HDC;
begin
edit1.Text :=athread.Connection.ReadLn();
temp:=edit1.Text ;
if temp=READY then
begin
c.Connect();
C.WriteLn(ZHUNBEI);
Fullscreen:=TBitmap.Create;
Fullscreen.Width := Screen.Width;
Fullscreen.Height := Screen.Height;
DC:=GetDC(0);
FullscreenCanvas := TCanvas.Create;//创建一个CANVAS对象
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect
(Rect(0,0,Screen.Width,Screen.Height),FullScreenCanvas,
Rect(0,0,Screen.Width,Screen.Height));
FullScreenCanvas.Free;
ReleaseDC(0,DC);
image1.Picture.Bitmap := FullScreen;//拷贝下的图象赋给IMAGE对象en
image1.Picture.SaveToFile('d:/1.bmp') ;
BMPToJPG('d:/1.bmp');
DeleteFile('d:/1.bmp');
image1.Picture.LoadFromFile('d:/1.jpg');
end;
if temp=FASONG then
begin
m:=TMemoryStream.Create;
Image1.Picture.Graphic.SaveToStream(m);
c.WriteLn(FASONG);
c.writestream(m);
m.Free ;
c.Disconnect ;
end;
end;
procedure Tform1.BMPToJPG(BmpFileName:string);
var
Jpeg : TJPEGImage;
Bmp : TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.LoadFromFile(BmpFileName);
Jpeg := TJPEGImage.Create;
try
Jpeg.Assign(Bmp);
Jpeg.Compress;
Jpeg.SaveToFile('d:/1.jpg');
finally
Jpeg.Free;
end;
finally
Bmp.Free;
end;
end;
end.