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

5
  • There are many code samples around that show how to take screenshots Jan 11, 2016 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. Jan 11, 2016 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" Jan 11, 2016 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. Jan 11, 2016 at 16:25
  • Let us continue this discussion in chat. Jan 11, 2016 at 16:28

5 Answers 5

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.

1
  • This is the right choice
    – SAMPro
    Oct 11, 2021 at 17:23
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;
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;
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.