使用c#中的像素 [英] Working with pixels in c#

查看:96
本文介绍了使用c#中的像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#在Visual Studio 2013中开发一个Windows窗体应用程序。



我需要找到picturebox1的图像的每个像素是白色然后转换它们变成红色。



这是我的伪代码:

----------------- ----------------------------------

foreach(picturebox1.Image中的白色像素)

{

将白色像素变为红色;

}

-------- --------------------------------------------



这是基本想法吗?如果没有,我怎么能实现呢?

请提供一些关于tutriols或文章的链接。



任何形式的帮助都将是赞。

i am developing a windows form application in Visual studio 2013 using c#.

I need to find each pixels of a image of picturebox1 which are white and then convert them into red.

This is my pseudocode:
---------------------------------------------------
foreach(White pixels in picturebox1.Image)
{
turn the white pixels to red ;
}
----------------------------------------------------

Is this the basic idea ? If not how can i acheive it ?
Please provide some links to tutriols or articles.

Any kind of help would be appreciated.

推荐答案

是的 - 最简单的方法就是使用Bitmap.GetPixel [ ^ ]和Bitmap.SetPixel [ ^ ] - 有更快的方法进行处理,但是它们需要不安全的代码和指针,所以我首先要使用它们!



注意白色是一个含糊不清的概念:它具有特定的含义就o而言f位图 - 基本上是完整的R,G和B - 但就我们的眼睛而言,有一系列RBG值显示为白色或白色。您可能会发现随机图像中的实际白色非常少,需要提供某些描述的白度偏移。
Yes - the simplest way is just to use Bitmap.GetPixel[^]and Bitmap.SetPixel[^] - there are faster ways of doing the processing, but they require unsafe code and pointers, so I'd get it working with these first!

Do note that "white" is an ambiguous concept: it has a specific meaning in terms of bitmaps - full R, G, and B, basically - but as far as our eyes are concerned there are a range of RBG values which appear "white" or "off white". You may find there is very little actual "white" in a random image and need to provide a "whiteness" offset of some description.


这篇关于使用c#中的像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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