国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi圖象截取編程示例(4)

2019-11-18 18:12:11
字體:
來源:轉載
供稿:網友
 

(六)TMainForm的 (抓圖)Action 事件
1)全屏抓圖
[Capture Desktop]  Action 事件
PRocedure TMainForm.cptDesktopExecute(Sender: TObject);
begin
  inc(CaptureNum,1);
  application.Minimize ;  //窗體最小化
  Delay(500);             //最小化后延時,為了全屏抓圖不把自身抓進圖中
  FileName:='Capture'+IntToStr(CaptureNum)+'.bmp';
  FileName:=DefaultDirectory+FileName;
  CreateMDIChild(FileName,true);
  StatusBar.SimpleText := FileName;
  with ActiveMDIChild as TMDIChild do begin
    Image1.Picture.Bitmap := CaptureScreen;         //抓圖
    HorzScrollBar.Range := Image1.Picture.Width;
    VertScrollBar.Range := Image1.Picture.Height;
  end;
  Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
                     + ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
  application.Restore ;
end;

2)區域抓圖
   抓取區域圖片,即要用到一個新的Form1,參見《Delphi圖象截取編程示例(6)》  .
   在Main單元implementation的uses中添加Capture1。
   在Main單元添加私有過程CaptureArea :

procedure TMainForm.CaptureArea;
begin
  with TForm1.Create(Application) do
  try
    if ShowModal=mrOK then
    with fRect do begin
      if (Right>Left)and(Bottom>Top) then begin
        Delay(400);
        ABitmap:=TBitmap.Create;
        ABitmap.Assign(CaptureScreenRect(fRect));
        Child.Image1.Picture.Bitmap:=ABitmap;
        Child.ClientWidth := Child.Image1.Picture.Width ;
        Child.ClientHeight:= Child.Image1.Picture.Height;
        Child.HorzScrollBar.Range:=Child.Image1.Picture.Width ;
        Child.VertScrollBar.Range:=Child.Image1.Picture.Height;
        ABitmap.Free ;
      end else begin
        MessageDlg('選擇圖片區域錯誤,請重新選擇!',mtInformation,[mbOK],0);
        Child.Close ;
        Form1.Free ;
        exit;
      end;
    end;
  finally
    Free;
  end;
end;

[Capture Area]區域抓圖的Action 事件
procedure TMainForm.cptAreaExecute(Sender: TObject);
begin
  Inc(CaptureNum,1);
  Application.Minimize ;
  Delay(500);
  FileName:='Capture'+IntToStr(CaptureNum)+'.bmp';
  FileName:=DefaultDirectory+FileName;
  { Create MDI Child Window }
  CreateMDIChild(FileName,true);
  StatusBar.SimpleText := FileName;

  { Capture Area of screen }
  CaptureArea;
  Child.Image1.Hint := 'Height:'+intToStr(child.Image1.Picture.Height)+'pixels'
                     + ' Width:'+intToStr(child.Image1.Picture.Width)+'pixels';
  application.Restore ;
end;


上一篇:Delphi圖象截取編程示例(5)

下一篇:Delphi圖象截取編程示例(3)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 海口市| 榆树市| 逊克县| 桓仁| 涡阳县| 娄底市| 祁门县| 元江| 团风县| 焦作市| 康平县| 龙井市| 治县。| 和田市| 正定县| 盐津县| 武夷山市| 桐梓县| 阳原县| 遵义县| 小金县| 板桥市| 大埔区| 永寿县| 锡林浩特市| 湘西| 永昌县| 朝阳市| 鹤庆县| 长治县| 宣武区| 孝感市| 仲巴县| 天水市| 辉县市| 佛学| 涿鹿县| 上高县| 舞钢市| 安仁县| 张北县|