Einzelnen Beitrag anzeigen

jensw_2000
(Gast)

n/a Beiträge
 
#2

Re: Videogrösse an Panel anpassen

  Alt 12. Feb 2005, 11:39
Habe das hier mal in der DP gefunden ...
Leider kann ich den Beitrag jetzt nicht mehr finden ... aber es funktioniert super ...

Delphi-Quellcode:
function GetRect(Panel: TPanel): TRect;
var Width, Height: Integer; newWidth, newHeight: Single; T: Integer;
begin
  Result := Panel.ClientRect;
  if not GetSizeInfo(frmDetails.MediaPlayer.FileName, Width, Height) then exit;
  newWidth := (Width * (Result.Bottom - Result.Top)) / Height;
  newHeight := (Height * (Result.Right - Result.Left)) / Width;
  if (newWidth < (Result.Right - Result.Left)) and
     (newHeight > (Result.Bottom - Result.Top)) then
  begin
    T := Round((Result.Right - Result.Left - newWidth) / 2);
    Inc(Result.Left, T);
    Dec(Result.Right, 2*T);
  end
  else if (newHeight < (Result.Bottom - Result.Top)) and
          (newWidth > (Result.Right - Result.Left)) then
  begin
    T := Round((Result.Bottom - Result.Top - newHeight) / 2);
    Inc(Result.Top, T);
    Dec(Result.Bottom, 2*T);
  end
end;
Delphi-Quellcode:
// Größe des Videos auslesen
function GetSizeInfo(Name: string; var Width, Height: Integer): Boolean;
var dwParam2: TMCI_OVLY_RECT_PARMS;
    Retval: longint;
begin
  Result := false;
  dwParam2.dwCallback := MediaPlayer.Handle;
  dwParam2.rc.Left := 0;
  dwParam2.rc.Top := 0;
  dwParam2.rc.Right := 0;
  dwParam2.rc.Bottom := 0;
  Retval := mciSendCommand(MediaPlayer.DeviceID,MCI_WHERE, MCI_OVLY_WHERE_SOURCE, integer(@dwParam2));
  if Retval <> 0 then exit;
  Width := dwParam2.rc.Right - dwParam2.rc.Left;
  Height := dwParam2.rc.Bottom - dwParam2.rc.Top;
  Result := true;
end;
Aufruf mit

Delphi-Quellcode:
      
      Mediaplayer.FileName:=...videofile...;
      MediaPlayer.Open;
      Mediaplayer.DisplayRect:=getRect(VideoPanel);
  Mit Zitat antworten Zitat