除了通过像素旅行BMP C# [英] Exception on traveling through pixels BMP C#

查看:207
本文介绍了除了通过像素旅行BMP C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用下面的代码去旅行虽然BMP的像素,因为这



 的for(int i = 0; I< =图片。宽度;我++)
{
为(INT J = 0; J< = Image.Height; J ++)
{
色= Image.GetPixel(I,J); //获取
}

}



但即时得到一个例外

  System.ArgumentOutOfRangeException了未处理
消息=参数必须是正和< Height.\r\\ \
Parameter名称:Y
来源=System.Drawing中
PARAMNAME =Y

我不知道为什么即时得到这个..使用 BMP 与有效高度,并与正常工作硬编码值相同的代码IM



@Odded



没有:1显示我需要什么,2号是什么与我们的代码发生任何想法




< DIV CLASS =h2_lin>解决方案

只要改变高度和宽度。这是在寻找自己的代码太远这样一个例子 - 这回带来了如此多的回忆..

 为(INT I = 0; I< BMP.Height;我++)
{
为(INT J = 0; J< BMP.Width; J ++)
{
色= BMP.GetPixel( J,I);
}
}


Im using the following code to travel though the pixels of a BMP as this

for (int i = 0; i <= Image.Width; i++)
 {
    for (int j = 0; j <= Image.Height; j++)
    {
              color = Image.GetPixel(i, j); //get 
    }

 }

but im getting a exception

System.ArgumentOutOfRangeException was unhandled
  Message="Parameter must be positive and < Height.\r\nParameter name: y"
  Source="System.Drawing"
  ParamName="y"

I have no clue why im getting this.. im using a BMP with valid heights and same code with hard-coded values working correctly

@Odded

No:1 Shows what i needed and no 2 is whats happening with ur code any idea?

解决方案

Just change Height and Width. This is such an example of looking too far in your own code - this brings back so many memories..

for(int i=0;i<BMP.Height;i++)
{
   for(int j=0;j<BMP.Width;j++)
   {
      color = BMP.GetPixel(j,i);    
   }
}

这篇关于除了通过像素旅行BMP C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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