Как сохранить веб страничку в JPEG

Советы » Браузер » Как сохранить веб страничку в JPEG

procedure

generateJPEGfromBrowser(browser: iWebBrowser2; jpegFQFilename: String

; srcHeight: Integer; srcWidth: Integer; tarHeight: Integer; tarWidth: Integer); var

sourceDrawRect : TRect; targetDrawRect: TRect; sourceBitmap: TBitmap; targetBitmap: TBitmap; jpeg: TJPEGImage; viewObject: IViewObject; begin

sourceBitmap := TBitmap.Create ; targetBitmap := TBitmap.Create ; jpeg := TJPEGImage.Create ; try

try

sourceDrawRect := Rect(0,0, srcWidth , srcHeight ); sourceBitmap.Width := srcWidth ; sourceBitmap.Height := srcHeight ; viewObject := browser as

IViewObject; if

viewObject = nil

then

Exit; OleCheck(viewObject.Draw(DVASPECT_CONTENT, 1, nil

, nil

, self.Handle, sourceBitmap.Canvas.Handle, @sourceDrawRect, nil

, nil

, 0)); // Resize Bitmap targetDrawRect := Rect(0,0, tarWidth, tarHeight); targetBitmap.Height := tarHeight; targetBitmap.Width := tarWidth; targetBitmap.Canvas.StretchDraw(targetDrawRect, sourceBitmap); // Create JPEG from Bitmap and save it jpeg.Assign(targetBitmap) ; makeFileWriteable(jpegFQFilename); jpeg.SaveToFile (jpegFQFilename); finally

jpeg.free; sourceBitmap.free ; targetBitmap.free; end

; except

// errors end

; end

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com