如何把TWEBBROWSER中显示的带滚动条的页面保存成.bmp的图片(100)

  • 主题发起人 主题发起人 sssdamn
  • 开始时间 开始时间
S

sssdamn

Unregistered / Unconfirmed
GUEST, unregistred user!
把页面显示的内容保存成.bmp的图片,如何实现啊
 
别处抄的:procedure GenerateJPEGfromBrowser(browser: iWebBrowser2; jpegFQFilename: string; srcHeight: integer; srcWidth: integer; tarHeight: integer; tarWidth: integer);var sourceDrawRect: TRect; targetDrawRect: TRect; sourceBitmap : TBitmap; targetBitmap : TBitmap; aJPG : TJPEGImage; aViewObject : IViewObject;begin sourceBitmap := TBitmap.Create; targetBitmap := TBitmap.Create; aJPG := TJPEGImage.Create; try try sourceDrawRect := Rect(0, 0, srcWidth, srcHeight); sourceBitmap.Width := srcWidth; sourceBitmap.Height := srcHeight; aViewObject := browser as IViewObject; if aViewObject=nil then Exit; OleCheck(aViewObject.Draw(DVASPECT_CONTENT, 1, nil, nil, Form1.Handle, sourceBitmap.Canvas.Handle, @sourceDrawRect, nil, nil, 0)); targetDrawRect := Rect(0, 0, tarWidth, tarHeight); targetBitmap.Height := tarHeight; targetBitmap.Width := tarWidth; targetBitmap.Canvas.StretchDraw(targetDrawRect, sourceBitmap); aJPG.Assign(targetBitmap); aJPG.SaveToFile(jpegFQFilename) finally aJPG.Free; sourceBitmap.Free; targetBitmap.Free end; { try } except end;end;//调用--------------------------var IDoc1: IHTMLDocument2; Web : iWebBrowser2; tmpX, tmpY : integer;begin with WebBrowser1 do begin tmpX := Height; tmpY := Width; Height := OleObject.Document.Body.getAttribute('scrollHeight', 0) + GetSystemMetrics(SM_CXVSCROLL)+3;// .ParentWindow.Screen.Height+1000; Width := OleObject.Document.Body.getAttribute('scrollwidth', 0) + GetSystemMetrics(SM_CXVSCROLL)+3;//.ParentWindow.Screen.Width; GenerateJPEGfromBrowser(ControlInterface, 'demo1.jpg', Height, Width, Height, Width); Height := tmpX; Width := tmpY; end;
 
上面这段代码是能实现抓图,但是滚动条下面的,看不到的,还是抓不到
 
混个脸熟
 
.......不知道你试了没,反正我这是可以截整个页面的,包括滚动条以下的
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部