C产品在市场上有哪些独特优势?
- 内容介绍
- 文章标签
- 相关推荐
本文共计762个文字,预计阅读时间需要4分钟。
csharp[DllImport(user32.dll)]private static extern IntPtr GetDC(IntPtr hwnd);
[DllImport(gdi32.dll)]private static extern int GetPixel(IntPtr hdc, Point p);
public static Color getColor(Point p){ // Point p=new Point(MousePosition.X,}
[DllImport(
"user32.dll"
)]
private
staticexternIntPtr GetDC(IntPtr hwnd);
[DllImport(
"gdi32.dll"
)]
private
staticexternintGetPixel(IntPtr hdc, Point p);
public
staticColor getColor(Point p)
{
// Point p = new Point(MousePosition.X, MousePosition.Y);//取置顶点坐标
IntPtr hdc = GetDC(
new
IntPtr(0));//取到设备场景(0就是全屏的设备场景)
int
c = GetPixel(hdc, p);//取指定点颜色
int
r = (c & 0xFF);//转换R
int
g = (c & 0xFF00) / 256;//转换G
int
b = (c & 0xFF0000) / 65536;//转换B
// pictureBox1.BackColor = Color.FromArgb(r, g, b);
return
Color.FromArgb(r, g, b);
}
测试例子:
private
voidbutton1_Click(objectsender, EventArgs e)
{
//测试X在200,Y在120 到500 的颜是否不等于 Color.FromArgb(255, 246, 246, 246);
string
d = DateTime.Now.ToLongTimeString();
Color cl = Color.FromArgb(255, 246, 246, 246);
Point p =
new
Point(200,0);
for
(inth = 120; h < 500; h+=8) {
p.Y = h;
if
(getColor(p).Equals(cl)==
false
){
Text =
""
+ h;
break
;
}
}
Text = d +
":"
+ DateTime.Now.ToLongTimeString() +
" "
+ p ;
}
本文共计762个文字,预计阅读时间需要4分钟。
csharp[DllImport(user32.dll)]private static extern IntPtr GetDC(IntPtr hwnd);
[DllImport(gdi32.dll)]private static extern int GetPixel(IntPtr hdc, Point p);
public static Color getColor(Point p){ // Point p=new Point(MousePosition.X,}
[DllImport(
"user32.dll"
)]
private
staticexternIntPtr GetDC(IntPtr hwnd);
[DllImport(
"gdi32.dll"
)]
private
staticexternintGetPixel(IntPtr hdc, Point p);
public
staticColor getColor(Point p)
{
// Point p = new Point(MousePosition.X, MousePosition.Y);//取置顶点坐标
IntPtr hdc = GetDC(
new
IntPtr(0));//取到设备场景(0就是全屏的设备场景)
int
c = GetPixel(hdc, p);//取指定点颜色
int
r = (c & 0xFF);//转换R
int
g = (c & 0xFF00) / 256;//转换G
int
b = (c & 0xFF0000) / 65536;//转换B
// pictureBox1.BackColor = Color.FromArgb(r, g, b);
return
Color.FromArgb(r, g, b);
}
测试例子:
private
voidbutton1_Click(objectsender, EventArgs e)
{
//测试X在200,Y在120 到500 的颜是否不等于 Color.FromArgb(255, 246, 246, 246);
string
d = DateTime.Now.ToLongTimeString();
Color cl = Color.FromArgb(255, 246, 246, 246);
Point p =
new
Point(200,0);
for
(inth = 120; h < 500; h+=8) {
p.Y = h;
if
(getColor(p).Equals(cl)==
false
){
Text =
""
+ h;
break
;
}
}
Text = d +
":"
+ DateTime.Now.ToLongTimeString() +
" "
+ p ;
}

