Getpixel返回值问题 [英] Getpixel return value problem

查看:570
本文介绍了Getpixel返回值问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..
我有一个问题..我想将颜色变量存储到数组中..
看我的代码

Hello..
I have a problem..i want to store a color variable to an array..
Let see my code

Bitmap* bmp = bmp->FromFile(L"coba.bmp", false);
Color color;







and

int i,j;
int width;
int height;
int matriks_gbr[10][10];
width = bmp->GetWidth();
height = bmp->GetHeight();
for (i=0;i<=height-1;i++)
{
	for (j=0;j<=width-1;j++)
	{
		matriks_gbr[i][j] = bmp->GetPixel(i,j,&color);
	}
}



只想检查matriks_gbr的内容:



and just wanna to check the content of matriks_gbr :

if (matriks_gbr[0][0] = RGB(255,255,255))
  AfxMessageBox(_T("works"), MB_OK);
else
  AfxMessageBox(_T("not works"), MB_OK);


它解决了(消息正常),但是当我将RGB(255,255,255)更改为非零数字如255或20时,它也显示为作品". 后来我知道了这个问题,getpixel只返回Ok和non-ok.
但是我想访问颜色并将其存储到数组中. 您能告诉我如何将其存储到数组吗?


It worked out (message works) , but when i changed to RGB(255,255,255) to nonzeero number like 255 or 20 , it also appeared "works".
Later i know the problem, getpixel only return Ok and non-ok.
But i want to access the color and store it to an array..
Can you tell me how to store it to array?

推荐答案

GetPixel(),此处引用的是API或您自己的.
如果是API,则返回COLORREF.
COLORREF GetPixel(
__在HDC hdc中,
__in int nXPos,
__in int nYPos
);

而不是拥有数组,
最好有一个结构向量.
在每个结构中,维护r,g和b的变量.
GetPixel() you referrig here means API or you have your own.
If its an API, it returns COLORREF.
COLORREF GetPixel(
__in HDC hdc,
__in int nXPos,
__in int nYPos
);

Rather than having the array,
Better have a vector of structures.
In each structure maintain variables for r,g, and b .


这篇关于Getpixel返回值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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