AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Image from TWebBrowser -> TPicture

Ein Thema von Ryzinski · begonnen am 18. Nov 2012 · letzter Beitrag vom 18. Nov 2012
Antwort Antwort
Ryzinski

Registriert seit: 2. Okt 2012
38 Beiträge
 
#1

Image from TWebBrowser -> TPicture

  Alt 18. Nov 2012, 20:56
hi!

i found a c# solution but i have no idea how to do this in delphi.

Code:
  IHTMLDocument2 doc = (IHTMLDocument2)wb1.Document.DomDocument;
            IHTMLControlRange imgRange = (IHTMLControlRange)((HTMLBody)doc.body).createControlRange();

            foreach (IHTMLImgElement img in doc.images)
            {
                if (img.nameProp.Contains('sometag'))
                {
                    IHTMLElementRenderFixed render = (IHTMLElementRenderFixed)img;
                    Bitmap bmp = new Bitmap(img.width, img.height);
                    Graphics g = Graphics.FromImage(bmp);
                    IntPtr hdc = g.GetHdc();
                    render.DrawToDC(hdc);
                    g.ReleaseHdc(hdc);

                    ImageBmp = bmp;
                    break;
                }
            }
        }
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Image from TWebBrowser -> TPicture

  Alt 18. Nov 2012, 21:59
It is nearly exact the same in delphi
Delphi-Quellcode:
var
  doc : IHTMLDocument2;
  imgRange : IHTMLControlRange;
  img : IHTMLImgElement;
  render : IHTMLElementRender;

  bmp : TBitmap;
  _hdc : HDC;

  img_NameProp : string;
  img_idx : Integer;
begin
  doc := Browser_WebBrowser.Document as IHTMLDocument2;
  imgRange := ( doc.body as HTMLBody ).createControlRange as IHTMLControlRange;

  for img_idx := 0 to Pred( doc.images.length ) do
    begin

      img := doc.images.item( img_idx, EmptyParam ) as IHTMLImgElement;

      img_NameProp := Utf8ToAnsi( UTF8Encode( img.nameProp ) );
      if ContainsText( img_NameProp, 'sometag' )
      then
        begin
          render := ( img as IHTMLElementRender );

          bmp := TBitmap.Create;
          try
            bmp.Width := img.Width;
            bmp.Height := img.Height;

            _hdc := bmp.Canvas.Handle;

            render.DrawToDC( _hdc );

            Image1.Picture.Assign( bmp );

          finally
            bmp.Free;
          end;
          break;
        end;
    end;
end;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (18. Nov 2012 um 22:09 Uhr)
  Mit Zitat antworten Zitat
Ryzinski

Registriert seit: 2. Okt 2012
38 Beiträge
 
#3

AW: Image from TWebBrowser -> TPicture

  Alt 18. Nov 2012, 22:22
// Whoops

Geändert von Ryzinski (18. Nov 2012 um 22:27 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#4

AW: Image from TWebBrowser -> TPicture

  Alt 18. Nov 2012, 22:26
Yes Mr. Joey Smith
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#5

AW: Image from TWebBrowser -> TPicture

  Alt 18. Nov 2012, 22:57
für alle die den jetzt nicht verstanden haben:
http://stackoverflow.com/questions/1...er-to-tpicture
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz