⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temasked.pas

📁 Do your applications look a little boring? Would you like to get spectacular yet easy to use visual
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      RandomStyle := Random(CountOfStyles) + 1;
    Result := RandomStyle;
  end                                                        
  else Result := FStyle;
end;

function TMaskedTransition.SubStyleToUse: Word;
begin
  if FSubStyle = 0
  then
  begin
    if RandomSubStyle = 0 then
      RandomSubStyle := Random(CountOfSubStyles(StyleToUse)) + 1;
    Result := RandomSubStyle;
  end
  else Result := FSubStyle;

  if ReversedToUse then
    Result := CalculateReversedSubStyle(StyleToUse, Result);
end;

function TMaskedTransition.CalculateReversedSubStyle(
  const StyleValue, SubStyleValue: Word): Word;
begin
  Result := SubStyleValue;  //EROC itnA
end;

procedure TMaskedTransition.ExecuteFrame(Data: TTETransitionData;
  CurrentFrame, Step, TotalFrames, LastExecutedFrame: Longint);
begin
  inherited;

  if not Smooth
  then ExecuteFrame1bpp(Data, CurrentFrame, Step,
         LastExecutedFrame, TotalFrames, Frame1bppMaskBmp, Frame1bppMaskBmp2,
         False, True, True)
  else ExecuteFrame8bpp(Data, CurrentFrame, Step, TotalFrames,
         LastExecutedFrame);
end;

function TMaskedTransition.ExecuteFrame1bpp(Data: TTETransitionData;
  CurrentFrame, Step, LastExecutedFrame: Longint;
  const TotalFrames: Longint; CurrentMask, PreviousMask: TBitmap;
  SmoothValue, Draw, CalcDirtyRects: Boolean): Boolean;
var
  Dst,
  Work,
  Mask: PDWordArray;
  j,
  k: Longint;
  ScanLineSize,
  MaskScanLineSize: Integer;
begin
  Result := True;
  if not AllowScreenUpdate then
  begin
    SelectPalette(RenderWindow.Canvas.Handle, RenderWindow.Palette, True);
    MaskFrame(CurrentMask, CurrentFrame, Step, TotalFrames,
      LastExecutedFrame, Data, Draw, CalcDirtyRects);
  end
  else
  begin
    MaskScanLineSize := GetBytesPerScanline(CurrentMask, pf1bit, 32);

    UpdateRect   := Rect(0, 0, Data.Width, Data.Height);
    UnUpdateRect := Rect(0, 0, 0, 0);
    MaskFrame(CurrentMask, CurrentFrame, Step, TotalFrames, LastExecutedFrame,
      Data, Draw, CalcDirtyRects);
    IntersectRect(UpdateRect, UpdateRect, Rect(0, 0, Data.Width, Data.Height));
    IntersectRect(UnUpdateRect, UnUpdateRect, UpdateRect);

    if not SmoothValue then
    begin
      if InversePaint then
      begin
        Mask := PDWordArray(PChar(CurrentMask.ScanLine[0]) + MaskScanLineSize);
        k    := -((CurrentMask.Width * (Data.Height)) div 32);
        InvertMask(Mask, k);
      end;

      if OptimizeMask then
      begin
        if DirtyRects.Count > 1
        then
        begin
          for j := 0 to DirtyRects.Count-1 do
            DoMaskOptimization(CurrentMask, PreviousMask, MaskScanLineSize,
              DirtyRects[j], Rect(0, 0, 0, 0));
        end
        else DoMaskOptimization(CurrentMask, PreviousMask, MaskScanLineSize,
               UpdateRect, UnUpdateRect);
      end;

      ScanLineSize := GetBytesPerScanline(Data.DstBmp, Data.PixelFormat, 32);
      Work := PDWordArray(PChar(Data.Bitmap.ScanLine[0]) + ScanlineSize);
      Dst  := PDWordArray(PChar(Data.DstBmp.ScanLine[0]) + ScanlineSize);
      Mask := PDWordArray(PChar(CurrentMask.ScanLine[0]) + MaskScanlineSize);
      if DirtyRects.Count > 1
      then
      begin
        for j := 0 to DirtyRects.Count-1 do
          Apply1bppMask(Work, Dst, Mask, CurrentMask.Width, ScanLineSize,
            MaskScanLineSize, Data.PixelFormat, DirtyRects[j], Rect(0, 0, 0, 0))
      end
      else
        Apply1bppMask(Work, Dst, Mask, CurrentMask.Width, ScanLineSize,
          MaskScanLineSize, Data.PixelFormat, UpdateRect, UnUpdateRect);
    end;
  end;
  if(not SmoothValue) and ResetMaskBmp then
    FillRect(CurrentMask.Canvas.Handle, UpdateRect, GetStockObject(WHITE_BRUSH));
end;

procedure TMaskedTransition.ExecuteFrame8bpp(Data: TTETransitionData;
  CurrentFrame, Step, TotalFrames, LastExecutedFrame: Longint);
const
  Optimize = True;
var
  aux: TBitmap;
  Work,
  Dst,
  Src,
  Mask,
  Mask2: Pointer;
  ScanLineSize,
  MaskScanLineSize,
  i,
  Frame,
  StartLevel,
  EndLevel,
  TopFrame,
  LowFrame,
  DecValue,
  Increment,
  FillFrames: Longint;
  DirtyRect,
  EmptyRect: TRect;

  procedure DrawFrame(Color, Frame, Step: Integer);
  begin
    if(Frame > 0) and (Frame <= TotalFramesValue) then
    begin
      Frame8bppMaskBmp.Canvas.Pen  .Color :=
        $02000000 or RGB(Color, Color, Color);
      Frame8bppMaskBmp.Canvas.Brush.Color := Frame8bppMaskBmp.Canvas.Pen.Color;
      ExecuteFrame1bpp(Data, Frame, Step, Frame-Step, TotalFramesValue,
        Frame8bppMaskBmp, nil, True, True, False);
    end;
  end;

  // Get the params
  procedure GetDecValue;
  begin
    if(LastExecutedFrame <> 0) 
    then
    begin
      DecValue := Step * StepLevel;
      if DecValue > MaxLevel then
        DecValue := MaxLevel;
    end
    else DecValue := 0;

    EndLevel := MaxLevel;
    if CurrentFrame > TotalFramesValue then
      Dec(EndLevel, (CurrentFrame - TotalFramesValue) * StepLevel);

    begin
      StartLevel := EndLevel - ((Step - 1) * StepLevel);
      if StartLevel < MinLevel
      then
      begin
        StartLevel := MinLevel;
        FillFrames := Step - (((EndLevel - StartLevel) div StepLevel) + 1 );
      end
      else
      begin
        FillFrames := 0;
        if StartLevel > EndLevel then
          StartLevel := EndLevel;
      end;
    end;

    TopFrame := CurrentFrame + ((EndLevel - MaxLevel) div StepLevel);
    if TopFrame > TotalFramesValue then
      TopFrame := TotalFramesValue;
    LowFrame := LastExecutedFrame - Levels;
    if LowFrame < 0 then
      LowFrame := 0;
  end;

begin
  {$ifdef LogTiming}
  if Assigned(CronoExtra) then
    CronoExtra.Start;
  {$endif LogTiming}

  MaskScanLineSize := GetBytesPerScanline(Frame8bppMaskBmp, pf8bit          , 32);
  ScanLineSize     := GetBytesPerScanline(Data.Bitmap     , Data.PixelFormat, 32);
  if AvoidPixelRepaint
  then
  begin
    aux               := Frame8bppMaskBmp;
    Frame8bppMaskBmp  := Frame8bppMaskBmp2;
    Frame8bppMaskBmp2 := aux;
    Mask2 := PChar(Frame8bppMaskBmp2.ScanLine[0]) + MaskScanLineSize;
  end
  else Mask2 := nil;
  Work := PChar(Data.Bitmap     .ScanLine[0]) + ScanlineSize;
  Dst  := PChar(Data.DstBmp     .ScanLine[0]) + ScanlineSize;
  Src  := PChar(Data.SrcBmp     .ScanLine[0]) + ScanlineSize;
  Mask := PChar(Frame8bppMaskBmp.ScanLine[0]) + MaskScanLineSize;

  GetDecValue;

  if(DecValue > 0) and (not AvoidPixelRepaint) then
  begin
    if DirtyRects.Count > 1
    then
    begin
      for i := 0 to DirtyRects.Count-1 do
        DoDecMask1(Mask, MaskScanLineSize, Frame8bppMaskBmp.Width, DecValue,
          DecValue = Levels, DirtyRects[i], Rect(0, 0, 0, 0));
    end
    else DoDecMask1(Mask, MaskScanLineSize, Frame8bppMaskBmp.Width, DecValue,
           DecValue = Levels, UpdateRectBak, UnUpdateRectBak);
  end;
  DirtyRects.Clear;

  if LastExecutedFrame < TotalFramesValue then
  begin
    if AvoidPixelRepaint
    then
    begin
      if InversePaint then
        DrawFrame(255, CurrentFrame + ((EndLevel - MaxLevel) div StepLevel) + 1, 1);
      i          := EndLevel;
      EndLevel   := StartLevel;
      StartLevel := i;
      Increment  := -StepLevel;
    end
    else
    begin
      if (FillFrames > 0)Then
      Begin
        If (InversePaint) then //V33
        Begin
          Self.Frame8bppMaskBmp.Canvas.Pen.Color:=TColor(RGB(0,0,0)Or $02000000);
          Self.Frame8bppMaskBmp.Canvas.Brush.Color:=Self.Frame8bppMaskBmp.Canvas.Pen.Color;
          Self.Frame8bppMaskBmp.Canvas.FillRect(Self.UpdateRectBak);
        End
        Else
          DrawFrame(0, LowFrame + FillFrames, FillFrames);
      End;
      Increment := StepLevel;
    end;

    i := StartLevel;
    // Draw the new levels
    repeat
      Frame := CurrentFrame + ((i - MaxLevel) div StepLevel);
      DrawFrame(i, Frame, 1);
      Inc(i, Increment);
    until i = EndLevel + Increment;
  end;

  if(not AvoidPixelRepaint) and InversePaint
  then DrawFrame(255, CurrentFrame + ((EndLevel - MaxLevel) div StepLevel) + 1, 1)
  else if(FillFrames > 0) and (not InversePaint) then
    DrawFrame(0, LastExecutedFrame + FillFrames, FillFrames);

  // Get the dirty rects
  ExecuteFrame1bpp(Data, TopFrame, TopFrame - LowFrame, LowFrame,
    TotalFramesValue, Frame8bppMaskBmp, nil, True, False, True);

  if(DecValue > 0) and AvoidPixelRepaint then
  begin
    if DirtyRects.Count > 1
    then
    begin
      for i := 0 to DirtyRects.Count-1 do
        DoDecMask2(Mask, Mask2, MaskScanLineSize, Frame8bppMaskBmp.Width,
          DecValue, DecValue = Levels, DirtyRects[i], Rect(0, 0, 0, 0));
    end
    else DoDecMask2(Mask, Mask2, MaskScanLineSize, Frame8bppMaskBmp.Width,
           DecValue, DecValue = Levels, UpdateRect, UnUpdateRect);
  end;

  if DirtyRects.Count > 1
  then
  begin
    EmptyRect := Rect(0, 0, 0, 0);
    for i := 0 to DirtyRects.Count-1 do
    begin
      DirtyRect := DirtyRects[i];
      Apply256MaskS(TApply256MaskSProc(Apply256MaskSProc), Work,
        Dst, Src, Mask, ScanLineSize, MaskScanLineSize, Frame8bppMaskBmp.Width,
        Data.Height, DirtyRect, EmptyRect);
      DirtyRects[i] := DirtyRect;
    end
  end
  else
    Apply256MaskS(TApply256MaskSProc(Apply256MaskSProc), Work,
      Dst, Src, Mask, ScanLineSize, MaskScanLineSize, Frame8bppMaskBmp.Width,
      Data.Height, UpdateRect, UnUpdateRect);

  {$ifdef LogTiming}
  if Assigned(CronoExtra) then
  begin
    CronoExtra.Pause;
    Trace[TraceIndex].ExTime := CronoExtra.Milliseconds;
    CronoExtra.Reset;
  end;
  {$endif LogTiming}
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -