2

I've embedded MPlayer video results into TPanel successfully, BUT can't copy TPanel results into a TImage.

ONLY the normal picture of TPanel is copied into TImage :

enter image description here

Embedding is performed using piping and MPlayer wid command line parameters. MPlayer using TPanel handle to display results.

The following snippets tested, but just normal TPanel picture copied into TImage:

  Image1.Picture.Bitmap.Canvas.CopyRect(
    Rect(0, 0, Image1.Width-1, Image1.Height-1),
    TMyPanel(Panel1).Canvas,     //TMyPanel is an empty class to access canvas property 
    Rect(0, 0, Panel1.Width-1, Panel1.Height-1)
  );

and this:

Function PanelToBmp ( Panel:TPanel):TBitmap;
VAR
  bmp : tBitmap;
  DC  : HDC;
Begin
  bmp := tBitmap.Create;
  bmp.width := Panel.Width;
  bmp.Height := Panel.Height;
  DC := GetDc ( Panel.Handle );
  Bitblt(bmp.canvas.handle, 0, 0, Panel.Width, Panel.Height, Dc, 0, 0, NOTSRCCOPY);
  Releasedc (Panel.handle,dc);
  result := bmp;
End;
SAMPro
  • 1,068
  • 1
  • 15
  • 39
  • 1
    I don't know MPlayer in particular, but often video is rendered a little bit differently and you can't take a 'normal' screenshot of it. I did find some information about MPlayer which suggests you need to start it with a specific parameter, after which you can let MPlayer make screenshots itself. Maybe there are ways to send such commands to your embedded MPlayer? See [this](http://www.systutorials.com/2990/taking-screenshot-in-mplayer/) and [this](http://mplayerhq.hu/pipermail/mplayer-users/2004-August/047721.html). – GolezTrol Jun 09 '16 at 08:14

1 Answers1

1

You also can copy through the clipboard, try this:

uses ClipBrd;

procedure TForm1.Button1Click(Sender: TObject);
var
  lBmp: TBitmap;
begin
  lBmp := TBitmap.Create;
  try
    lBmp.SetSize(Panel1.ClientWidth, Panel1.ClientHeight);
    BitBlt(lBmp.Canvas.Handle, 0, 0, Panel1.ClientWidth, Panel1.ClientHeight, TMyPanel(Panel1).Canvas.Handle, 0, 0, SRCCOPY);
    Clipboard.Assign(lBmp);

   Image1.Picture.Bitmap.Assign( lBmp );
  finally
    lBmp.Free;
  end;
end;

I hope this help you.

  • Thanks for the script, but doesn't worked. Like other scripts only show picture of a normal Panel. – SAMPro Jun 11 '16 at 08:50