- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi的获取某坐标的颜色值
1.通过API函数GetPixel(),获取某个点的颜色值;
var
PT : TPoint;
C : TColor;
DC : HDC;
hwd : THandle;
I : integer;
begin
GetCursorPos(PT);
hwd := WindowFromPoint(PT);
DC := GetDC(HWD);
C := GetPixel(DC,PT.x,PT.y);
// self.color := c; //设置窗体颜色
edit1.text := FORMAT($%.6x,[C]);
//下面在指定窗口句柄下面绘制一条直线;
for i := 0 to 800 do
begin
setPixel(DC,50,i,$233cc8);
end;
end;
获取的TColor颜色值为BGR格式($233cc8),和网页html的RGB格式相反,如要和delphi颜色效果相同,设置为#c83c23;