何如取得像素的颜色值,并将颜色值传换成一个整数? ( 积分: 100 )

  • 主题发起人 主题发起人 claire_cn
  • 开始时间 开始时间
The GetPixel function retrieves the red, green, blue (RGB) color value of the pixel at the specified coordinates.

COLORREF GetPixel(

HDC hdc, // handle of device context
int XPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
 
int1:=integer(canvas.Pixels[X, Y]);
 
先用tcanvas类的TColor取得像素的颜色,然后从Tcolor用与操作分离分量颜色,如:c,cr:TColor;
c:=取得颜色值
cr:=(c and $FF);//取得红色分量值,int 型的
 
to ak_2005:
可以详细点吗,写几句代码可以吗?

to hannuman:
int1:=-1 ???/
(不论图画怎么改,都是-1)

to huaxuewang:
c:=取得颜色值 ?// 关键是如何取得,我不知道
 
var
p: TPoint;
w: DWord;
DC: HDC;
begin
DC := GetDC(0);
GetCursorPos(p);
w := GetPixel(DC, p.x, p.y);
Result:=IntToStr(ColorToRGB(w));
end;
 
to ak_2005:
 
后退
顶部