这下是问题大了,我不敢结呀,这是在技术区! 算了,贴一段Alpha混合算法: procedure AlphaBlend(DestBitmap, SourceBitmap: TBitmap; ARect: TRect; BlendScale: Byte); var Source, Dest: ^Cardinal; x, y: Integer; C, CBRB, CBG: Cardinal; TmpRect, MidRect: TRect; StoreP: TPoint; begin if (DestBitmap = nil) or (SourceBitmap = nil) then exit; with TmpRect, DestBitmap do begin TopLeft := Point(0, 0); Bottom := Height; Right := Width; end; if not InterSectRect(TmpRect, TmpRect, ARect) then exit; StoreP := TmpRect.TopLeft; OffsetRect(TmpRect, -TmpRect.Left, -TmpRect.Top); with MidRect, SourceBitmap do begin TopLeft := Point(0, 0); Bottom := Height; Right := Width; end; if not InterSectRect(TmpRect, TmpRect, MidRect) then exit; if DestBitmap.PixelFormat <> pf32bit then DestBitmap.PixelFormat := pf32bit; if SourceBitmap.PixelFormat <> pf32bit then SourceBitmap.PixelFormat := pf32bit; {$WARNINGS OFF} with TmpRect do case BlendScale of 255: for y := Top To Bottom - 1 do begin Source := SourceBitmap.ScanLine[y]; Dest := DestBitmap.ScanLine[y + StoreP.y]; Move(Source^, Dest^, (Right - Left) * SizeOf(Cardinal)); end; 0:; else for y := Top to Bottom - 1 do begin Source := SourceBitmap.ScanLine[y]; Dest := DestBitmap.ScanLine[y + StoreP.Y]; Inc(Dest, StoreP.X); for x := Left to Right do begin if Source^ <> Dest^ then begin CBRB := (Dest^ and $00FF00FF) * (255 - BlendScale); CBG := (Dest^ and $0000FF00) * (255 - BlendScale); C := ((Source^ and $00FF00FF) * BlendScale + CBRB) and $FF00FF00 + ((Source^ and $00FF00) * BlendScale + CBG) and $00FF0000; Dest^ := C shr 8; end; Inc(Source); Inc(Dest); end; end; end; {$WARNINGS ON} end;
在Controls单元的初始部分,以下是代码!procedure InitControls;
var
UserHandle: HMODULE;
begin
WindowAtomString := Format('Delphi%.8X',[GetCurrentProcessID]);
WindowAtom := GlobalAddAtom(PChar(WindowAtomString));
ControlAtomString := Format('ControlOfs%.8X%.8X', [HInstance, GetCurrentThreadID]);
ControlAtom := GlobalAddAtom(PChar(ControlAtomString));
RM_GetObjectInstance := RegisterWindowMessage(PChar(ControlAtomString));
CanvasList := TThreadList.Create;
InitIMM32;
Mouse := TMouse.Create;
Screen := TScreen.Create(nil);
Application := TApplication.Create(nil);
Application.ShowHint := True;
RegisterIntegerConsts(TypeInfo(TCursor), IdentToCursor, CursorToIdent);
UserHandle := GetModuleHandle('USER32');
if UserHandle <> 0 then
@AnimateWindowProc := GetProcAddress(UserHandle, 'AnimateWindow');
end;{ TCustomListControl }procedure TCustomListControl.MoveSelection(
Destination: TCustomListControl);
begin
CopySelection(Destination);
DeleteSelected;
end;initialization
NewStyleControls := Lo(GetVersion) >= 4;
InitControls;
StartClassGroup(TControl);
ActivateClassGroup(TControl);
GroupDescendentsWith(TCustomImageList, TControl);
GroupDescendentsWith(TContainedAction, TControl);
GroupDescendentsWith(TCustomActionList, TControl);finalization
FreeAndNil(DockSiteList);
DoneControls;end.
算了,贴一段Alpha混合算法:
procedure AlphaBlend(DestBitmap, SourceBitmap: TBitmap;
ARect: TRect; BlendScale: Byte);
var
Source, Dest: ^Cardinal;
x, y: Integer;
C, CBRB, CBG: Cardinal;
TmpRect, MidRect: TRect;
StoreP: TPoint;
begin
if (DestBitmap = nil) or (SourceBitmap = nil) then exit; with TmpRect, DestBitmap do
begin
TopLeft := Point(0, 0);
Bottom := Height;
Right := Width;
end;
if not InterSectRect(TmpRect, TmpRect, ARect) then exit; StoreP := TmpRect.TopLeft;
OffsetRect(TmpRect, -TmpRect.Left, -TmpRect.Top); with MidRect, SourceBitmap do
begin
TopLeft := Point(0, 0);
Bottom := Height;
Right := Width;
end;
if not InterSectRect(TmpRect, TmpRect, MidRect) then exit; if DestBitmap.PixelFormat <> pf32bit then
DestBitmap.PixelFormat := pf32bit; if SourceBitmap.PixelFormat <> pf32bit then
SourceBitmap.PixelFormat := pf32bit; {$WARNINGS OFF}
with TmpRect do
case BlendScale of
255:
for y := Top To Bottom - 1 do
begin
Source := SourceBitmap.ScanLine[y];
Dest := DestBitmap.ScanLine[y + StoreP.y];
Move(Source^, Dest^, (Right - Left) * SizeOf(Cardinal));
end;
0:;
else
for y := Top to Bottom - 1 do
begin
Source := SourceBitmap.ScanLine[y];
Dest := DestBitmap.ScanLine[y + StoreP.Y]; Inc(Dest, StoreP.X);
for x := Left to Right do
begin
if Source^ <> Dest^ then
begin
CBRB := (Dest^ and $00FF00FF) * (255 - BlendScale);
CBG := (Dest^ and $0000FF00) * (255 - BlendScale);
C := ((Source^ and $00FF00FF) * BlendScale + CBRB) and $FF00FF00 +
((Source^ and $00FF00) * BlendScale + CBG) and $00FF0000;
Dest^ := C shr 8;
end;
Inc(Source);
Inc(Dest);
end;
end;
end;
{$WARNINGS ON}
end;
代码段中调用 InitControls;
建立了
Application和Screen对象。
楼主的Alpha混合算法干什么用的?
还是想着接接分吧!
接分不能白接,给你几个delphi新闻组吧!!!
新闻组
borland.public.delphi.activex.controls.using
borland.public.delphi.activex.controls.writing
borland.public.delphi.database.desktop
borland.public.delphi.database.multi-tier
borland.public.delphi.database.sqlservers
borland.public.delphi.graphics
borland.public.delphi.ide
borland.public.delphi.internet
borland.public.delphi.jobs
borland.public.delphi.non-technical
borland.public.delphi.objectpascal
borland.public.delphi.oleautomation
borland.public.delphi.opentoolsapi
borland.public.delphi.reporting-charting
borland.public.delphi.thirdparty-tools
borland.public.delphi.vcl.components.using
borland.public.delphi.vcl.components.writing
borland.public.delphi.winapi
alt.comp.lang.borland-delphi
comp.lang.pascal.delphi.components.misc
comp.lang.pascal.delphi.components.usage
comp.lang.pascal.delphi.components.writing
comp.lang.pascal.delphi.databases
comp.lang.pascal.delphi.misc
直接说先Screen后application不就得了
算法收藏了