Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TMediaPlayer.Display >>> TImage 1

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hi all,

I have been working on a program that extracts pictures
from movies. Now I want to do this by by allowing the
user to browse the frames and then select the image they
want to save as a picture. I got the browsing part working
but I can't get it to export it to the TImage component.

I have tried codes like this:
Code:
[b]MediaPlayer1.Display.PaintTo(Image1.Picture.Bitmap.Canvas.Handle ,-1,-1);[/b]

Now this seems to do some good but when I save the image
I only get a large gray area.

Does anyone have any information or tips I might
be able to use?

Thanx allot,

BobbaFet Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Have a look at the following code. It is a different aproach to the one you were taking, but I think it will do what you want.

This assumes that you are using panel1 as the TMedia display

Code:
implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
begin
 GrabArea(Image1.Picture.BitMap);
end;

Procedure TForm1.GrabArea(myBitMap: TBitMap);
var myCanvas: TCanvas;
    r, toCapture: TRect;
    handleToWindow: THandle;
begin
 myCanvas:= TCanvas.Create;
 myCanvas.Handle:= GetWindowDC (GetDesktopWindow);
 handleToWindow:=GetForeGroundWindow;
 if handleToWindow<>0 then
 GetWindowRect(handleToWindow, toCapture);
 try
  //******************************************************
  // Modify the 'toCapture' Rect to only be the area where
  // The Media control is displaying to (panel1)
  //******************************************************
  toCapture.left   := toCapture.left+  (4+Panel1.Left);
  toCapture.top    := toCapture.top +  (23+panel1.top);
  toCapture.bottom := toCapture.top +  panel1.height;
  toCapture.Right  := toCapture.Left + panel1.Width;
  r:= Rect(0,0,toCapture.Right-toCapture.left,toCapture.Bottom-toCapture.Top);
  myBitMap.Width:=toCapture.Right-toCapture.left;
  myBitMap.Height:=toCapture.Bottom-toCapture.Top;
  myBitMap.Canvas.CopyRect(r, myCanvas, toCapture);
 finally
  ReleaseDC(0, myCanvas.handle);
  myCanvas.Free;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  image1.Picture.SaveToFile('c:\my.bmp');
end;

end.

This works by getting a handle to the window and then geting the rect courdinates of the window. This is the rect that will be grabbed, I then go on to modify this rect to cover only the co-ords of the controle that is being used by the media player.

Finaly I grab this area as a bitmap and asign it to the image.

And hey-Presto X-) Billy H

bhogar@acxiom.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top