Einzelnen Beitrag anzeigen

Benutzerbild von Cylence
Cylence

Registriert seit: 2. Sep 2004
Ort: Allgäu
246 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: VideoWindowEx bei Resize verschieben

  Alt 5. Sep 2011, 15:22
Hi,

evtl hilft dir diese funktion damit wärs glaub ich möglich:

Delphi-Quellcode:
function StretchRectEx(aRect : TRect; VideoAspectRatio : TPoint;
     SubtitleHeight, SubtitleNonOverlappedRows, SubtitleMaxRows,
     VideoVertShift, VideoHorizShift, VideoZoom: integer; StretchRatio : integer;
     out Centered : boolean): TRect;
var
  imgW, imgH, // video width, height
  imgWzoom, imgHzoom, // zoomed video width, height
  rectW, rectH, // destination width, height
  TmpTop : Integer; // aux for video top
begin
  rectW := aRect.Right - aRect.Left;
  rectH := aRect.Bottom - aRect.Top;
  imgW := rectW;
  imgH := MulDiv(imgW, VideoAspectRatio.Y, VideoAspectRatio.X);
   if imgH > rectH then begin
       imgH := rectH;
       imgW := MulDiv(imgH, VideoAspectRatio.X, VideoAspectRatio.Y);
     end;
  imgH := MulDiv(imgH, StretchRatio, 100);
  TmpTop := (rectH - imgH) div 2;
  if (rectH - (TmpTop + imgH)) < (SubtitleHeight * SubtitleNonOverlappedRows) then
    Centered := true
  else begin
      Centered := false;
      TmpTop := (rectH - imgH - SubtitleMaxRows * SubtitleHeight) div 2;
    end;
  imgWzoom := MulDiv(imgW, VideoZoom, 100);
  imgHzoom := MulDiv(imgH, VideoZoom, 100);
  TmpTop := TmpTop + (imgH - imgHzoom) div 2;
  Result := Bounds(aRect.Left + (rectW - imgWzoom) div 2 + VideoHorizShift,aRect.Top + TmpTop + VideoVertShift, imgWzoom, imgHzoom);
end;

ach ja und wie man sie ausführt:

Delphi-Quellcode:
var
  BasicVideo2 : IBasicVideo2;
  R : TRect;
  centering : boolean;
begin
  Centering := True;
  if Succeeded(ActiveFiltergraph.QueryInterface(IID_IBasicVideo2, BasicVideo2)) then begin
      R := StretchRectEx(MRVideoWindow.ClientRect, // BoundsRect,
         Point(Trunc(ASpx.Value),Trunc(Aspy.Value)),0,0,0,
         Trunc(Vertshift.Value), Trunc(horzshift.Value),
         Trunc(ZoomX.Value), 100, centering);
       BasicVideo2.SetDestinationPosition(R.Left, R.Top,
         (R.Right - R.Left), (R.Bottom - R.Top));
      BasicVideo2 := nil;
    end;
Tom
Just DO it

Geändert von Cylence ( 5. Sep 2011 um 15:26 Uhr) Grund: hab noch was hinzugefügt
  Mit Zitat antworten Zitat