本文介绍了颜色类型的条件语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我已经写了这样的代码

Hello Everyone
I have written such code like this

UINT width = bmp->GetWidth();
UINT height = bmp->GetHeight();

cout << "The Width is   " << width;
for(i=0;i<width;i++)>
{
	//cout << "Tes";
	for(j=0;j<height;j++)>
	{

	   bmp->GetPixel(i,j,&color);
	   if(color = 255,255,255)
	   {
				
		mxCoordinateX[l]= i;l++;
	        mxCoordinateY[m]= j;m++;
				
	   }
        }
}



但是关于argb的运行时错误



but there was an error in run time regarding argb

Status status = SetStatus(DllExports::GdipBitmapGetPixel(
static_cast<gpbitmap>(nativeImage),
x, y,        
&argb));



我的程序想通过检查像素是否为黑色来获取白色背景位图中矩形(未填充,仅是线)的坐标,然后保存坐标,但是出现错误,我在上面显示了它.你能给我建议吗?
感谢



my program wants get coordinate of rectangle (unfilled, just line) in a white-background bitmap by check if the pixel is black then save the coordinates but error appeared i showed it above..
Could you give me advice?
Thanks

推荐答案

if(color = 255,255,255)

做你想做的事.

首先,在C ++中,operator =是赋值运算符,而不是相等运算符.

其次,在C ++中,当通常需要一个表达式并且结果取自最右边的一个表达式时,逗号允许多个表达式.

因此,该声明实质上等同于:

probably does do what you think it does.

First, in C++, operator = is assignment operator and not equality operator.

Second, in C++, a comma allows multiple expressions when normally one expression is expected and the result is taken from the rightmost one.

Thus, that statement would essentially be equivalent to:

255;
255;
color = 255;
if (color) { ... }


有关更多信息,请查看:
http://www.cplusplus.com/doc/tutorial/operators/ [ ^ ]

还有:
http://msdn.microsoft.com/en-us/library/zs06xbxh (v = VS.100).aspx [ ^ ]


For more information, take a look at:
http://www.cplusplus.com/doc/tutorial/operators/[^]

And also:
http://msdn.microsoft.com/en-us/library/zs06xbxh(v=VS.100).aspx[^]


这篇关于颜色类型的条件语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 17:57