procedure
TForm1
.
SetZoom(Value:
Integer
);
var
Ratio:
Real
;
BasicVideo: IBasicVideo2;
TmpLeft, TmpX, TmpTop, TmpY:
Real
;
SetLeft, SetTop, SetWidth, SetHeight:
Integer
;
begin
if
(Value <
0
)
or
(Value >
99
)
then
begin
raise
Exception
.
CreateFmt(
'Значение %d по ракурсу. Значение допустимое от 0 и 99'
, [Value]);
Exit;
end
;
if
(csDesigning
in
ComponentState)
or
(pVideoRenderer =
nil
)
then
begin
pZoom := Value;
Exit;
end
;
BasicVideo :=
nil
;
try
if
(pVideoRenderer
.
QueryInterface(IID_IBasicVideo2, BasicVideo) = S_OK)
then
begin
BasicVideo
.
SetDefaultSourcePosition;
BasicVideo
.
Get_SourceLeft(SetLeft);
BasicVideo
.
Get_SourceTop(SetTop);
BasicVideo
.
Get_SourceWidth(SetWidth);
BasicVideo
.
Get_SourceHeight(SetHeight);
Ratio := SetHeight / SetWidth;
TmpX := SetWidth - ((Value * SetWidth) /
100
);
TmpY := TmpX * Ratio;
TmpLeft := (SetWidth - TmpX) /
2
;
TmpTop := (SetHeight - TmpY) /
2
;
BasicVideo
.
Put_SourceWidth(Trunc(TmpX));
BasicVideo
.
Put_SourceHeight(Trunc(TmpY));
BasicVideo
.
Put_SourceLeft(Trunc(TmpLeft));
BasicVideo
.
Put_SourceTop(Trunc(TmpTop));
end
;
pZoom := Value;
finally
BasicVideo :=
nil
;
end
;
Exit;
end
;