C#从点x和y获得像素颜色 [英] C# get pixel color from point x and y

查看:108
本文介绍了C#从点x和y获得像素颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在尝试制作一些游戏,我需要你的帮助。我有面板控制,在那个面板中我放了两张图片:

背景图片:黑色,中间有一条蓝线

可移动图像:红色图像可以向左移动,正确,向上,向下。



我想移动图像投掷黑色图片但是当它点击蓝线时停止,可移动图像不应该通过投掷蓝线...

怎么做,读取像素颜色或任何其他方式?





谢谢!

Hello,

i am trying to make some game, and i need your help. I have panel control and in that panel i put two images:
Background image: black with one blue line on middle
Movable image: Red image whick can be moved left,right,up,down.

I want to move image throw black picture but when it hit blue line it stop, movable image should not pass throw blue line...
How to do that, to read pixel color or any other way?


Thanks!

推荐答案

在这里你可以找到一个很好的解决方案为你的问题。



Bitmap.GetPixel方法 [ ^ ]



Here you can find a good solution for your problem.

Bitmap.GetPixel Method[^]

// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");

// Get the color of a pixel within myBitmap.
Color pixelColor = myBitmap.GetPixel(50, 50);
}


这篇关于C#从点x和y获得像素颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆