山
山东好汉
Unregistered / Unconfirmed
GUEST, unregistred user!
我知道D3D是不会出现这个问题的,因为32位alpha通道BMP位图,边缘会有一些非透明纯黑色的的部分,所以用DelphiX的TDirectDrawSurface.Draw函数绘制的时候会出现边缘的黑点无法被透明,请高手指点!谢谢!函数源码:procedure TDirectDrawSurface.Draw(X, Y: Integer; SrcRect: TRect; Source: TDirectDrawSurface; Transparent: Boolean);const BltFastFlags: array[Boolean] of Integer = (DDBLTFAST_NOCOLORKEY or DDBLTFAST_WAIT, DDBLTFAST_SRCCOLORKEY or DDBLTFAST_WAIT); BltFlags: array[Boolean] of Integer = (DDBLT_WAIT, DDBLT_KEYSRC or DDBLT_WAIT);var DestRect: TRect; DF: TDDBltFX; Clipper: IDirectDrawClipper; i: Integer;begin if Source <> nil then begin if (X > Width) or (Y > Height) then Exit;{$IFDEF DrawHWAcc} //硬件加速 if AsSigned(D2D) and D2D.CanUseD2D and (D2D.FDDraw.Surface = Self) then begin {$IFDEF VER4UP} D2D.D2DRenderDrawDDSXY(Source, X, Y, SrcRect, Transparent, 0, rtDraw{$IFNDEF VER4UP}, $FF{$ENDIF}); {$ELSE} D2D.D2DRenderDDS(Source, Bounds(X, Y, SrcRect.Right - SrcRect.Left, SrcRect.Bottom - SrcRect.Top), Transparent, 0, rtDraw, $FF); {$ENDIF} Exit; end;{$ENDIF DrawHWAcc} if (SrcRect.Left > SrcRect.Right) or (SrcRect.Top > SrcRect.Bottom) then begin { Mirror } if ((X + Abs(SrcRect.Left - SrcRect.Right)) <= 0) or ((Y + Abs(SrcRect.Top - SrcRect.Bottom)) <= 0) then Exit; DF.dwsize := SizeOf(DF); DF.dwDDFX := 0; if SrcRect.Left > SrcRect.Right then begin i := SrcRect.Left; SrcRect.Left := SrcRect.Right; SrcRect.Right := i; DF.dwDDFX := DF.dwDDFX or DDBLTFX_MIRRORLEFTRIGHT; end; if SrcRect.Top > SrcRect.Bottom then begin i := SrcRect.Top; SrcRect.Top := SrcRect.Bottom; SrcRect.Bottom := i; DF.dwDDFX := DF.dwDDFX or DDBLTFX_MIRRORUPDOWN; end; with SrcRect do DestRect := Bounds(X, Y, Right - Left, Bottom - Top); if ClipRect2(DestRect, SrcRect, ClientRect, Source.ClientRect) then begin if DF.dwDDFX and DDBLTFX_MIRRORLEFTRIGHT <> 0 then begin i := SrcRect.Left; SrcRect.Left := Source.Width - SrcRect.Right; SrcRect.Right := Source.Width - i; end; if DF.dwDDFX and DDBLTFX_MIRRORUPDOWN <> 0 then begin i := SrcRect.Top; SrcRect.Top := Source.Height - SrcRect.Bottom; SrcRect.Bottom := Source.Height - i; end; Blt(DestRect, SrcRect, BltFlags[Transparent] or DDBLT_DDFX, df, Source); end; end else begin with SrcRect do DestRect := Bounds(X, Y, Right - Left, Bottom - Top); if ClipRect2(DestRect, SrcRect, ClientRect, Source.ClientRect) then begin if FHasClipper then begin DF.dwsize := SizeOf(DF); DF.dwDDFX := 0; Blt(DestRect, SrcRect, BltFlags[Transparent], df, Source); end else begin BltFast(DestRect.Left, DestRect.Top, SrcRect, BltFastFlags[Transparent], Source); if DXResult = DDERR_BLTFASTCANTCLIP then begin ISurface.GetClipper(Clipper); if Clipper <> nil then FHasClipper := True; DF.dwsize := SizeOf(DF); DF.dwDDFX := 0; Blt(DestRect, SrcRect, BltFlags[Transparent], df, Source); end; end; end; end; end;end;