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

📄 salphagraph.pas

📁 Alpha Controls.v5.46b Source
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                  Rect(MaskData.R.Left + dw,
                       MaskData.R.Top,
                       MaskData.R.Left + dw + wl - 1,
                       MaskData.R.Top + wt - 1));
    if (scLeftBottom in Corners) then // left - bottom
      CopyTransCorner(SrcBmp, 0, Height - wb,
                  Rect(MaskData.R.Left,
                       MaskData.R.Bottom - wb,
                       MaskData.R.Left + wl - 1,
                       MaskData.R.Bottom - 1));
    if (scRightBottom in Corners) then // right - bottom
      CopyTransCorner(SrcBmp, Width - wr, Height - wb,
                  Rect(MaskData.R.Left + dw + wl + w,
                       MaskData.R.Bottom - wb,
                       MaskData.R.Left + dw + wl + w + wr - 1,
                       MaskData.R.Bottom - 1));
    if (scRightTop in Corners) then // right - top
      CopyTransCorner(SrcBmp, Width - wr, 0,
                  Rect(MaskData.R.Left + dw + wl + w,
                       MaskData.R.Top,
                       MaskData.R.Left + dw + wl + w + wr - 1, 
                       MaskData.R.Top + wb - 1));
  end
  else begin
    if (scLeftTop in Corners) then
      CopyMasterCorner(Rect(0, 0, wl + 1, wt + 1), Rect(MaskData.R.Left + dw, MaskData.R.Top, MaskData.R.Left + dw + wl, MaskData.R.Top + wt), SrcBmp);
    if (scLeftBottom in Corners) then
    // left - bottom
      CopyMasterCorner(Rect(0, Height - wb, wl, Height), Rect(MaskData.R.Left + dw, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl, MaskData.R.Top + dh), SrcBmp);
    if (scRightBottom in Corners) then
    // right - bottom
      CopyMasterCorner(Rect(Width - wr, Height - wb, Width, Height), Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl + w + wr, MaskData.R.Top + dh), SrcBmp);
    if (scRightTop in Corners) then
    // right - top
      CopyMasterCorner(Rect(Width - wr, 0, Width, wt), Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Top, MaskData.R.Left + dw + wl + w + wr, MaskData.R.Top + wt), SrcBmp);
  end;
  ParentCenterColor := clFuchsia;
end;

{$ENDIF}

{ TacFast24 }

function TacFast24.Attach(Bmp: TBitmap) : boolean;
begin
  if (Bmp.Height > 1) and (Bmp.Width > 1) then begin
    FBitmap := Bmp;
    FWidth := FBitmap.Width;
    FHeight := FBitmap.Height;
    Assert(FBitmap.PixelFormat = pf24bit, 'Bitmap format is not supported');
    FStart := Integer(FBitmap.Scanline[0]);
    FDelta := Integer(FBitmap.Scanline[1]) - FStart;
    Result := True;
  end
  else begin
    FWidth := 0;
    Result := False;
  end;
end;

procedure TacFast24.SetPixel(X, Y: Integer; const Value: TsColor);
asm
  push eax
  push ebx
  push ecx
  push edx
  imul ecx,[eax].FDelta
  add ecx,[eax].FStart
  lea edx,[edx+edx*2]
  mov eax,[ebp+8]  //Value
  bswap eax
  shr eax, 8
  mov [ecx+edx],ax
  shr eax, 16
  mov [ecx+edx+2],al
  pop edx
  pop ecx
  pop ebx
  pop eax
end;

function TacFast24.GetPixel(X, Y: Integer): TsColor;
asm
  push ebx
  push ecx
  push edx
  imul ecx,[eax].FDelta
  add ecx,[eax].FStart
  add ecx,edx
  movzx eax,WORD PTR [ecx+2*edx]
  bswap eax
  shr eax,8
  movzx ecx, BYTE PTR [ecx+2*edx+2]
  or eax,ecx
  pop edx
  pop ecx
  pop ebx
end;

{ TacFastSum24 }

function TacFastSum24.Attach(BmpSrc, BmpDst: TBitmap) : boolean;
begin
  if (BmpSrc.Height > 1) and (BmpDst.Height > 1) and (BmpSrc.Width > 1) and (BmpDst.Width > 1) then begin
    FBmpSrc := BmpSrc;
    FBmpDst := BmpDst;

    FWidthDst := min(FBmpDst.Width, FBmpSrc.Width);
    FHeightDst := min(FBmpDst.Height, FBmpSrc.Height);
    FStartSrc := longint(FBmpSrc.Scanline[0]);
    FStartDst := longint(FBmpDst.Scanline[0]);
    FDeltaDst := longint(FBmpDst.Scanline[1]) - FStartDst;
    FDeltaSrc := longint(FBmpSrc.Scanline[1]) - FStartSrc;
    Result := True;
  end
  else Result := False;
end;

procedure TacFastSum24.BlendBitmaps;
var
  x, y : integer;
  SrcOffset : integer;
  a, b : byte;
asm
  mov cl, [eax].Alpha;
  mov a, cl                 // Alpha value

  mov ch, 255
  sub ch, cl
  mov b, ch                 // Beta value

  mov ecx, 0
  mov ecx, [eax].FHeightDst
  dec ecx                   // Max Y receiving
@DecY:
  mov Y, ecx

  mov ebx, [eax].FWidthDst
  jz @Next2
  imul ebx, 3
@Next2:
  dec ebx
  mov X, ebx                // Max X receiving

  mov edx, Y
  imul edx, [eax].FDeltaSrc
  add edx, [eax].FStartSrc  // Src offset

  mov SrcOffset, edx

  mov edx, Y
  imul edx, [eax].FDeltaDst
  add edx, [eax].FStartDst  // Dst offset

  mov ecx, X
@DecX:

  mov ebx, 0
  mov bl, BYTE PTR [edx + ecx] // EBX - destination byte
  push edx
  push eax

  mov edx, SrcOffset
  // (C2 * alpha + beta * C1 + 127 ) / 255
  mov eax, 0
  mov al, a
  imul ebx, eax

  push ebx

  mov ebx, 0
  mov bl, b
  mov eax, 0
  mov al, BYTE PTR [edx + ecx]  // EAX - source byte

  imul eax, ebx

  pop ebx

  add eax, ebx
  add eax, 127

  mov bl, ah                    // shl al, 8 Result byte - in BL

  pop eax
  pop edx
  mov BYTE PTR [edx + ecx], bl  // Moving the result byte

  dec ecx
  cmp ecx, 0
  jns @DecX

  mov ecx, Y
  dec ecx
  cmp ecx, 0

  jns @DecY
end;

procedure TacFastSum24.BlendBitmapsRect;
var
  x, y, minX, maxX, SrcXOffset, SrcYOffset : integer;
  SrcOffset : integer;
  a, b : byte;
asm
  mov cl, [eax].Alpha;
  mov a, cl                 // Alpha value
  mov ch, 255
  sub ch, cl
  mov b, ch                 // Beta value


  mov ebx, [eax].DstX1


  mov edx, ebx
  sub edx, [eax].SrcX1
  imul edx, 3

  mov SrcXOffset, edx

  imul ebx, 3
  mov MinX, ebx             // Max X in MaxX variable

  mov ebx, [eax].DstX2
  imul ebx, 3
  dec ebx
  mov MaxX, ebx             // Max X in MaxX variable

  xor ecx, ecx
  mov ecx, [eax].DstY2

  mov ebx, ecx
  sub ebx, [eax].SrcY2
//  imul ebx, [eax].FDeltaSrc
  mov SrcYOffset, ebx

  dec ecx
@DecY:
  mov Y, ecx
  mov ebx, MaxX
  mov X, ebx                // Min DstX2 receiving

  mov edx, Y
  sub edx, SrcYOffset
  imul edx, [eax].FDeltaSrc
  add edx, [eax].FStartSrc  // Src offset
  mov SrcOffset, edx

  mov edx, Y
  imul edx, [eax].FDeltaDst
  add edx, [eax].FStartDst  // Dst offset

  mov ecx, X
@DecX:
  xor ebx, ebx
  mov bl, BYTE PTR [edx + ecx] // EBX - destination byte
  push edx
  push eax

  mov edx, SrcOffset
  // (C2 * alpha + beta * C1 + 127 ) / 255
  xor eax, eax
  mov al, a
  imul ebx, eax

  push ebx

  xor ebx, ebx
  mov bl, b
  xor eax, eax
  sub edx, SrcXOffset
  mov al, BYTE PTR [edx + ecx]  // EAX - source byte

  imul eax, ebx

  pop ebx

  add eax, ebx
  add eax, 127

  mov bl, ah                    // shl al, 8 and result byte - in BL

  pop eax
  pop edx
  mov BYTE PTR [edx + ecx], bl  // Moving the result byte

  dec ecx
  cmp ecx, MinX
  jns @DecX

  mov ecx, Y
  dec ecx
  cmp ecx, [eax].DstY1

  jns @DecY
end;

{ TacFast32 }

function TacFast32.Attach(Bmp: TBitmap): boolean;
begin
  if (Bmp.Height > 1) and (Bmp.Width > 1) then begin
    FBitmap := Bmp;
    FWidth := FBitmap.Width;
    FHeight := FBitmap.Height;
    Assert(FBitmap.PixelFormat = pf32bit, 'Bitmap format is not supported');
    FStart := longint(FBitmap.Scanline[0]);
    FDelta := longint(FBitmap.Scanline[1]) - FStart;
    Result := True;
  end
  else begin
    FWidth := 0;
    Result := False;
  end;
end;

function TacFast32.GetPixel(X, Y: Integer): TsColor;
asm
  push ebx
  push ecx
  push edx
  imul ecx, [eax].FDelta
  add ecx, [eax].FStart
  mov eax, [ecx + 4 * edx]
  bswap eax

  shr eax, 8
  xor ebx, ebx
  mov bl, al
  shl ebx, 24
//  shr eax, 8 v5.33
  add eax, ebx
  pop edx
  pop ecx
  pop ebx
end;

procedure TacFast32.SetPixel(X, Y: Integer; const Value: TsColor);
asm
  push eax
  push ebx
  push ecx
  push edx
  imul ecx, [eax].FDelta
  add ecx, [eax].FStart
  mov eax, Value
  bswap eax

  xor ebx, ebx
  mov bl, al
  shl ebx, 24
  shr eax, 8
  add eax, ebx
  mov [ecx + 4 * edx], eax
  pop edx
  pop ecx
  pop ebx
  pop eax
end;

initialization
  Fast24Src := TacFast24.Create;
  Fast24Dst := TacFast24.Create; 
  FastSum24 := TacFastSum24.Create;
  Fast32Src := TacFast32.Create;

finalization
  FreeAndNil(Fast24Src);
  FreeAndNil(Fast24Dst);
  FreeAndNil(FastSum24);
  FreeAndNil(Fast32Src);
end.




⌨️ 快捷键说明

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