PDA

View Full Version : GetPixel code here!!!



kornalius
26-05-2003, 05:48 PM
Why is this code doesn't work? I get nil values in the d3dlocked record.

function GetPixel(D: TPowerDraw; x, y: integer): Cardinal;
var
d3dlocked: TD3DLocked_Rect;
Offset: integer;
r: TRect;
dc: Hdc;
i: HResult;
begin
{D.BackBuffer[1].GetDC(dc);
Result := Windows.GetPixel(dc, x, y);
D.BackBuffer[1].ReleaseDC(dc);}

SetRect(r, x, y, x + 1, y + 1);
i := D.BackBuffer[0].LockRect(d3dlocked, @r, D3DLOCK_DONOTWAIT or D3DLOCK_READONLY);
Offset := (y * d3dlocked.Pitch) + (x * 2);
Result := DWord(Pointer(Integer(d3dLocked.Bits) + Offset)^);
D.BackBuffer[0].UnlockRect;
end;

Regards,
Kornalius