📄 tepage.pas
字号:
unit tePage;
interface
{$RANGECHECKS OFF}
{$INCLUDE teDefs.inc}
uses
SysUtils, Classes, TransEff, teTimed, Windows, Messages, Graphics, teRender;
type
{$ifndef TE_NOHLP}
TTERect = class;
TTERects = class
private
List: TList;
public
OrgDir,
TgtDir: TTEEffectDirection;
constructor Create(OrgDirValue, TgtDirValue: TTEEffectDirection);
destructor Destroy; override;
function CreateRect(ClipWidth, ClipHeight, Left, Top, Right,
Bottom: Integer): TTERect;
function TgtBottom(Rect: TTERect): Integer;
function TgtLeft(Rect: TTERect): Integer;
function TgtRight(Rect: TTERect): Integer;
function TgtTop(Rect: TTERect): Integer;
end;
TTERect = class
private
Rects: TTERects;
function GetBottom: Integer;
function GetLeft: Integer;
function GetRight: Integer;
function GetTop: Integer;
procedure SetBottom(const Value: Integer);
procedure SetLeft(const Value: Integer);
procedure SetRight(const Value: Integer);
procedure SetTop(const Value: Integer);
public
ClipWidth,
ClipHeight: Integer;
R: TRect;
constructor Create(RectsValue: TTERects);
function Height: Integer;
function Width: Integer;
function TgtHeight: Integer;
function TgtWidth: Integer;
property Left: Integer read GetLeft write SetLeft;
property Top: Integer read GetTop write SetTop;
property Right: Integer read GetRight write SetRight;
property Bottom: Integer read GetBottom write SetBottom;
function TgtLeft: Integer;
function TgtTop: Integer;
function TgtRight: Integer;
function TgtBottom: Integer;
function TgtR: TRect;
function UpdR: TRect;
end;
{$endif TE_NOHLP}
TPageTransition = class(TTimedTransitionEffect)
private
FSize: Byte;
FUncover: Boolean;
FUse3D: Boolean;
procedure Apply3D(IsReversed: Boolean; Dir: TTEEffectDirection; ArcData,
ArcRevData: PByteArray; ArcCustomData, ArcRevCustomData: PDWordArray; ArcBmp:
TBitmap; ArcRect: TRect; OrgBmp: TBitmap; OrgRect: TRect; ArcVisPixelCount:
Integer);
procedure Apply3DHrz(IsReversed: Boolean; ArcData: PDWordArray; Dst:
PByteArray; DstIndex, DstUpdRowLen: Longint; Src: PByteArray; SrcIndex:
Longint);
procedure Apply3DVrt(IsReversed: Boolean; ArcData, Dst: PByteArray;
DstIndex, DstUpdRowLen, DstUpdGap: Longint; Src: PByteArray;
SrcIndex, SrcUpdGap: Longint);
protected
procedure Initialize(Data: TTETransitionData; var TotalFrames: Longint);
override;
procedure ExecuteFrame(Data: TTETransitionData; CurrentFrame, Step,
LastExecutedFrame: Longint); override;
function GetInfo(Device: TTETransitionDevice): TTETransitionInfo; override;
function GetPixelFormat(Device: TTETransitionDevice): TPixelFormat; override;
function UncoverToUse: Boolean;
public
constructor Create(AOwner: TComponent = nil); override;
class function Description: String; override;
procedure Assign(Source: TPersistent); override;
class function GetEditor: String; override;
function Is3D(Device: TTETransitionDevice): Boolean;
published
property Direction default tedLeft;
property Pass2Options;
property PassSetting;
property Reversed;
property Size: Byte read FSize write FSize default 150;
property Uncover: Boolean read FUncover write FUncover default True;
property Use3D: Boolean read FUse3D write FUse3D default True;
end;
implementation
uses teMskWk;
type
TPageData = class(TTECustomData)
public
ArcData: PByteArray; // Array containing the pixel count for each position in the arc
ArcCustomData: PDWordArray; // Arc data with custom calculations
ArcLightMap: PByteArray; // Arc lighting
ArcPixelCount: Integer; // Number of pixels in each arc
ArcPreCalc: PWordArray; // Total pixels accumulated for each item in ArcData
ArcRevData: PByteArray; // Array containing the pixel count for each position in the reversed arc
ArcRevLightMap: PByteArray; // Reversed arc lighting
ArcVisPixelCount: Integer; // Number of visible pixels in each arc
BmpArc: TBitmap; // Bitmap for offscreen rendering of the arc
BmpArcRev: TBitmap; // Bitmap for offscreen rendering of the reversed arc
BmpReversed: TBitmap; // Contains the reversed org bitmap
Bmp: TBitmap; // The org bitmap
Direction: TTEEffectDirection;
Height: Integer;
DoScroll: Boolean; // Allow scrollin pixels
R1Arc3D: TTERect;
R1ArcRev3D: TTERect;
R2Arc3D: TTERect;
R2ArcRev3D: TTERect;
RArc: TTERect; // Regular arc rect
RArcRev: TTERect; // Reversed arc rect
RClip: TTERect; // Clipping rect
Rects: TTERects;
RMovingPg: TTERect; // Moving page rect
RMovingPgBak: TTERect;
RMovingPgNew: TTERect;
RStaticPg: TTERect; // Static page rect
RVisArc: TTERect; // Visible regular arc rect
RVisArcRev: TTERect; // Visible reversed arc rect
Width: Integer;
constructor Create(AData: TTETransitionData; Size: Integer;
Uncover: Boolean; Dir: TTEEffectDirection); reintroduce;
destructor Destroy; override;
end;
constructor TPageData.Create(AData: TTETransitionData; Size: Integer;
Uncover: Boolean; Dir: TTEEffectDirection);
begin
inherited Create(AData);
if Uncover
then Direction := Dir
else
begin
case Dir of
tedRight : Direction := tedLeft;
tedLeft : Direction := tedRight;
tedDown : Direction := tedUp;
tedUp : Direction := tedDown;
end;
end;
if Size > 0 then
begin
GetMem (ArcData , Size * 2); // Maximum of 2 * radius
ZeroMemory(ArcData , Size * 2);
GetMem (ArcRevData , Size * 2);
GetMem (ArcPreCalc , Size * 2 * 2);
GetMem (ArcLightMap , Size * 2);
ZeroMemory(ArcLightMap , Size * 2);
GetMem (ArcRevLightMap, Size * 2);
GetMem (ArcCustomData , Size * 2 * 4);
BmpArc := TBitmap.Create;
BmpArc .Canvas.Lock;
BmpArcRev := TBitmap.Create;
BmpArcRev.Canvas.Lock;
end;
ArcPixelCount := 0;
ArcVisPixelCount := 0;
BmpReversed := TBitmap.Create;
BmpReversed.Canvas.Lock;
Rects := TTERects.Create(tedDown, Direction);
end;
destructor TPageData.Destroy;
begin
if Assigned(ArcData ) then
FreeMem(ArcData);
if Assigned(ArcRevData ) then
FreeMem(ArcRevData);
if Assigned(ArcPreCalc ) then
FreeMem(ArcPreCalc);
if Assigned(ArcLightMap ) then
FreeMem(ArcLightMap);
if Assigned(ArcRevLightMap) then
FreeMem(ArcRevLightMap);
if Assigned(ArcCustomData ) then
FreeMem(ArcCustomData);
if Assigned(BmpArc ) then
begin
BmpArc .Canvas.Unlock;
BmpArc .Free;
end;
if Assigned(BmpArcRev ) then
begin
BmpArcRev .Canvas.Unlock;
BmpArcRev .Free;
end;
if Assigned(BmpReversed) then
begin
BmpReversed.Canvas.Unlock;
BmpReversed.Free;
end;
Rects.Free;
inherited;
end;
{ TPageTransition }
constructor TPageTransition.Create(AOwner: TComponent);
begin
inherited;
AllowedDirections := [tedRight, tedLeft, tedDown, tedUp, tedRandom];
Direction := tedLeft;
FSize := 150;
FUncover := True;
FUse3D := True;
end;
procedure TPageTransition.Apply3D(IsReversed: Boolean; Dir: TTEEffectDirection;
ArcData, ArcRevData: PByteArray; ArcCustomData, ArcRevCustomData:
PDWordArray; ArcBmp: TBitmap; ArcRect: TRect; OrgBmp: TBitmap; OrgRect:
TRect; ArcVisPixelCount: Integer);
var
ArcUpdParams,
OrgUpdParams: TTEUpdParams;
ArcScanLineSize,
OrgScanLineSize,
SavePos: Integer;
ArcPixels,
OrgPixels: PChar;
UnUpdateRect: TRect;
SaveValue: DWord;
OrgCorr: Byte;
begin
ArcScanLineSize := GetBytesPerScanline(ArcBmp, pf32bit, 32);
OrgScanLineSize := GetBytesPerScanline(OrgBmp, pf32bit, 32);
ArcPixels := PChar(ArcBmp.ScanLine[0]) + ArcScanlineSize;
OrgPixels := PChar(OrgBmp.ScanLine[0]) + OrgScanlineSize;
UnUpdateRect := Rect(0, 0, 0, 0);
GiveMeTheUpdParams(2, ArcUpdParams, ArcScanLineSize, ArcRect, UnUpdateRect,
pf32bit);
case Dir of
tedDown:
begin
GiveMeTheUpdParams(2, OrgUpdParams, OrgScanLineSize, OrgRect,
UnUpdateRect, pf32bit);
{$ifdef LogTiming}
if Assigned(Log) then
Log.ChronoExtra.Start;
{$endif LogTiming}
Apply3DHrz(
IsReversed,
ArcCustomData,
PByteArray(ArcPixels - ArcUpdParams.Start1),
-ArcUpdParams.Lenght1 * 4,
ArcUpdParams.RowLenght1 * 4,
PByteArray(OrgPixels - OrgUpdParams.Start1),
-OrgUpdParams.Lenght1 * 4);
{$ifdef LogTiming}
if Assigned(Log) then
Log.ChronoExtra.Pause;
{$endif LogTiming}
end;
tedUp:
begin
if OrgRect.Bottom > OrgBmp.Height
then
begin
OrgCorr := OrgRect.Bottom - OrgBmp.Height;
OrgRect.Bottom := OrgBmp.Height;
end
else OrgCorr := 0;
if IsReversed
then SavePos := 0
else SavePos := ArcVisPixelCount - (ArcRect.Bottom - ArcRect.Top);
SaveValue := ArcRevCustomData[SavePos];
GiveMeTheUpdParams(2, OrgUpdParams, OrgScanLineSize, OrgRect,
UnUpdateRect, pf32bit);
ArcRevCustomData[SavePos] :=
ArcRevCustomData[SavePos] - DWord(OrgCorr * OrgScanLineSize);
try
{$ifdef LogTiming}
if Assigned(Log) then
Log.ChronoExtra.Start;
{$endif LogTiming}
Apply3DHrz(
IsReversed,
PDWordArray(@ArcRevCustomData[SavePos]),
PByteArray(ArcPixels - ArcUpdParams.Start1),
-ArcUpdParams.Lenght1 * 4,
ArcUpdParams.RowLenght1 * 4,
PByteArray(OrgPixels - OrgUpdParams.Start1),
-OrgUpdParams.Lenght1 * 4);
{$ifdef LogTiming}
if Assigned(Log) then
Log.ChronoExtra.Pause;
{$endif LogTiming}
finally
ArcRevCustomData[SavePos] := SaveValue;
end;
end;
tedRight:
begin
if OrgRect.Left < 0
then
begin
OrgCorr := -OrgRect.Left;
OrgRect.Left := 0;
end
else OrgCorr := 0;
if IsReversed
then SavePos := 0
else SavePos := ArcVisPixelCount - (ArcRect.Right - ArcRect.Left);
SaveValue := ArcRevCustomData[SavePos];
// Assert(ArcRevCustomData[SavePos] >= OrgCorr);
GiveMeTheUpdParams(2, OrgUpdParams, OrgScanLineSize, OrgRect,
UnUpdateRect, pf32bit);
ArcRevCustomData[SavePos] := ArcRevCustomData[SavePos] - (OrgCorr * 4);
try
Apply3DVrt(
IsReversed,
PByteArray(@ArcRevCustomData[SavePos]),
PByteArray(ArcPixels - ArcUpdParams.Start1),
-ArcUpdParams.Lenght1 * 4,
ArcUpdParams.RowLenght1 * 4,
ArcUpdParams.Gap1 * 4,
PByteArray(OrgPixels - OrgUpdParams.Start1),
-OrgUpdParams.Lenght1 * 4,
OrgUpdParams.Gap1 * 4);
finally
ArcRevCustomData[SavePos] := SaveValue;
end;
end;
tedLeft:
begin
GiveMeTheUpdParams(2, OrgUpdParams, OrgScanLineSize, OrgRect,
UnUpdateRect, pf32bit);
Apply3DVrt(
IsReversed,
PByteArray(ArcCustomData),
PByteArray(ArcPixels - ArcUpdParams.Start1),
-ArcUpdParams.Lenght1 * 4,
ArcUpdParams.RowLenght1 * 4,
ArcUpdParams.Gap1 * 4,
PByteArray(OrgPixels - OrgUpdParams.Start1),
-OrgUpdParams.Lenght1 * 4,
OrgUpdParams.Gap1 * 4);
end;
end;
end;
procedure TPageTransition.Apply3DHrz(IsReversed: Boolean; ArcData: PDWordArray;
Dst: PByteArray; DstIndex, DstUpdRowLen: Longint; Src: PByteArray;
SrcIndex: Longint);
var
i,
Limit: Longint;
Light: Byte;
begin
// Adjusts for common index
Inc(PChar(Src), SrcIndex - DstIndex);
i := 0;
if IsReversed
then
begin
while DstIndex < 0 do
begin
Limit := DstIndex + DstUpdRowLen;
while DstIndex < Limit do
begin
if Src[DstIndex ] > Dst[DstIndex+3]
then Dst[DstIndex ] := Src[DstIndex ] - Dst[DstIndex+3]
else Dst[DstIndex ] := 0;
if Src[DstIndex+1] > Dst[DstIndex+3]
then Dst[DstIndex+1] := Src[DstIndex+1] - Dst[DstIndex+3]
else Dst[DstIndex+1] := 0;
if Src[DstIndex+2] > Dst[DstIndex+3]
then Dst[DstIndex+2] := Src[DstIndex+2] - Dst[DstIndex+3]
else Dst[DstIndex+2] := 0;
Inc(DstIndex, 4);
end;
Inc(PChar(Src), ArcData[i]);
Inc(i);
end;
end
else
begin
while DstIndex < 0 do
begin
Limit := DstIndex + DstUpdRowLen;
while DstIndex < Limit do
begin
Light := -Dst[DstIndex+3];
if Src[DstIndex ] < Light
then Dst[DstIndex ] := Src[DstIndex ] + Dst[DstIndex+3]
else Dst[DstIndex ] := 255;
if Src[DstIndex+1] < Light
then Dst[DstIndex+1] := Src[DstIndex+1] + Dst[DstIndex+3]
else Dst[DstIndex+1] := 255;
if Src[DstIndex+2] < Light
then Dst[DstIndex+2] := Src[DstIndex+2] + Dst[DstIndex+3]
else Dst[DstIndex+2] := 255;
Inc(DstIndex, 4);
end;
Inc(PChar(Src), ArcData[i]);
Inc(i);
end;
end;
end;
procedure TPageTransition.Apply3DVrt(IsReversed: Boolean; ArcData,
Dst: PByteArray; DstIndex, DstUpdRowLen, DstUpdGap: Longint; Src: PByteArray;
SrcIndex, SrcUpdGap: Longint);
var
ArcDataGap,
Limit: Longint;
Light: Byte;
begin
// Adjusts for common index
ArcDataGap := DstUpdRowLen + DstUpdGap;
Inc(PChar(Src) , SrcIndex - DstIndex);
Dec(SrcUpdGap , DstUpdGap);
Dec(PChar(ArcData), DstIndex);
if IsReversed
then
begin
while DstIndex < 0 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -