moon (20.10.08 11:25)
Если 16 битный режим то вот этот код подайдёт:
const
imageWidth = 84;
imageHeight = 80;
Alpha = 127;
var
Pict : Array [0..imageWidth - 1, 0..imageHeight - 1] of
Word;
ColorKey : Word;
...
implementation
...
function TDxForm.Prepare : HRESULT;
var
desc : TDDSURFACEDESC2;
i, j : Integer;
hRet : HRESULT; begin
Result := DD_FALSE;
ZeroMemory (@desc, SizeOf(desc) );
desc.dwSize := SizeOf(desc);
hRet := FDDSImage.Lock (nil, desc, DDLOGK_WAIT, 0);
if Failed (hRet) then begin Result := hRet;
Exit;
end;
for i := 0 to imageWidth - 1 do
for j := 0 to imageHeight - 1 do
Pict [i, j] := PWORD (Integer (desc.lpSurface) + j * desc.lPitch + i * (ScreenBitDepth div
8))^;
ColorKey := Pict [0,0];
Result := FDDSImage.Unlock (nil);
end;
function TDXForm.Blend (const X, Y : Integer) : HRESULT;
var
desc : TDDSURFACEDESC2; i, j : Integer;
wrkPointer : PWORD;
sTemp, dTemp : WORD;
sb, db, sg, dg, sr, dr : Byte;
blue, green, red : Byte;
hRet : HRESULT;
begin
ZeroMemory (@desc, SizeOf (desc) ) ; desc.dwSize := SizeOf(desc);
hRet := FDDSBack.Lock (nil, desc, DDLOCK_WAIT, 0) ;
if Failed (hRet) then begin Result := hRet;
Exit;
end;
for i := 0 to imageWidth - 1 do
for j := 0 to imageHeight - 1 do
if Pict [i, j] <> ColorKey then
begin
wrkPointer := PWORD (Integer(desc.IpSurface) +
(Y + j) * desc.lPitch + (X + i) * (ScreenBitDepth div 8));
sTemp := Pict [i, j];
dTemp := wrkPointer^;
sb = sTemp and $lf;
db = dTemp and $lf;
sg = (sTemp shr 5) and $3f;
dg = (dTemp shr 5) and $3f;
sr = (sTemp shr 11) and $lf;
dr = (dTemp shr 11) and $lf;
blue := (ALPHA * (sb - db) shr 8) -t- db;
green := (ALPHA * (sg - dg) shr 8) + dg;
red := (ALPHA * (sr - dr) shr 8) + dr;
wrkPointer^ := blue or (green shl 5) or (red shl 11);
end;
Result := FDDSBack.Unlock (nil);
end;
И в обработчике onCreate проверяешь hRet:= Prepare;
if Failed(HreT) then ...