2

I couldnt find a proper way to get picture of the loaded document in tchromium vcl control in a form.

looking for a method to get document as a bitmap of file or stream. delphi / tchromium component

Zen Of Kursat
  • 2,672
  • 1
  • 31
  • 47
  • There are many code samples around that show how to take screenshots – David Heffernan Jan 11 '16 at 14:33
  • programmatically on delphi ? simply there is no partial case-insensitive keyword namely "picture","capture" or "bitmap" within all chromium vcl sources or its demos. – Zen Of Kursat Jan 11 '16 at 14:44
  • I think answer is no not possible. "it is not yet possible in CEF3, necessary API functions have been removed in CEF3" – Zen Of Kursat Jan 11 '16 at 14:54
  • also cef3 cant. but answer is dcef-r231. it was 1988 when I press first "print screen". printscreen only takes screen. but Im looking for "getting document area as a bitmap". a loaded document is mostly oversized the screen. – Zen Of Kursat Jan 11 '16 at 16:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/100399/discussion-between-n-ramos-and-david-heffernan). – Zen Of Kursat Jan 11 '16 at 16:28

5 Answers5

1

TChromium inherits TWinControl, thus it has a HANDLE that can be used with BitBlt to take a "Screenshot" of the specified component. This article pretty much covers it all.

1

Sorry for post on almost dead question, but for future devs its important know that chromium ( CEF4 ) have a method "Chromium.TakeSnapshot(bmp)" that get a screenshot of loaded component.

0

Save to picture function is no longer avaible in DCEF3.but cef-r2.31 has it.

procedure Tfmmain.Button1Click(Sender: TObject);
var
  lol:TPicture;
begin
  lol:=TPicture.Create;
  Chromium1.Browser.GetBitmap(PET_VIEW,lol.Bitmap);
  lol.SaveToFile('c:\lol.bmp');
  lol.Free;
  lol:=nil;
end;
Zen Of Kursat
  • 2,672
  • 1
  • 31
  • 47
0

I think it will be easier to take a snapshot from the entire application screen. Try this :

function screenshot: boolean;
var
  Bild : TBitmap;
  jpg : tjpegimage;
  c: TCanvas;
   r: TRect;
begin
try
   c := TCanvas.Create;
   bild := tbitmap.Create;
   c.Handle := GetWindowDC(GetDesktopWindow);
   try
    r := Rect(0, 0, Screen.Width, Screen.Height);
     Bild.Width := Screen.Width;
     Bild.Height := Screen.Height;
     Bild.Canvas.CopyRect(r, c, r);
     JPG := TJpegImage.Create;
     jpg.smoothing := true;
     jpg.CompressionQuality := 60 ;
     jpg.Assign(bild);
     jpg.compress;
     jpg.SaveToFile(dircamp+'\screen.jpg');
   finally
    ReleaseDC(0, c.Handle);
     Bild.free;
     jpg.free;
     c.Free;
   end;
except
end;
delphirules
  • 6,443
  • 17
  • 59
  • 108
0

The off screen renderer component has OnPaint method that is used to copy data to screen and you could use it for saving image

laggyluk
  • 195
  • 2
  • 14