请问如何取得CDC中每一个象素点的数据. 请问如何取得CDC中每一个象素点的数据. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 COLORREF GetPixel( HDC hdc, // handle to DC int nXPos, // x-coordinate of pixel int nYPos // y-coordinate of pixel); 问题是nXPos, nYPos这2个参数怎么得到..比我我有一副129*100的图,我怎么取得全的的象素点的数据 哦,可以直接从CBitmap对象获得。 响应鼠标的函数里有nxpos,nypos,或者getcursorpos函数。 用个for循环通过GetPixel把每个象素读入一个数组在消息函数里添家相应的代码比如onlbuttondown,里边有个参数cpoint point的,就是鼠标在客户区的位置 要想达到你的目的,不一定非要在一棵树上吊死,你可以用MatLab来实现,它将输出你所要的数据,然后再将Matlab与VC结合起来岂不是很美吗? 循环使用:COLORREF GetPixel( HDC hdc, // handle to DC int nXPos, // x-coordinate of pixel int nYPos // y-coordinate of pixel); HBITMAP hbmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), "你的位图.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE); if( hbmp == NULL ) return -1; CBitmap m_bmp; m_bmp.Attach( hbmp ); BITMAP bmp; m_bmp.GetBitmap(&bmp); CDC dc; CDC memDC; memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&m_bmp); POINT pt; COLORREF clr; for(int i=0; i<bmp.bmHeight; i++) { for(int j=0; j<bmp.bmWidth; j++) { pt.x = j; pt.y = i; clr = memDC.GetPixel(pt); } } 字符显示的问题 VC 把一个记录集的整型字段的值,赋给一个整型变量 请问如何在落子的时候添加音效? 【美文欣赏】作者的亲身经历 关于用CFileDialog打开多个文件buffer的问题 利用ShellExecute调用winrar压缩文件,如何知道是否压缩完 谁有FTP协议的详细资料? 各位帮忙提供一下SFC的开发资料 请问下列程序的结果,谢谢! 我该怎么用DrawEdge? win2k和win98串口通讯的区别 怎么让进程不能被任务管理器杀死?
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
在消息函数里添家相应的代码
比如onlbuttondown,里边有个参数cpoint point的,就是鼠标在客户区的位置
COLORREF GetPixel(
HDC hdc, // handle to DC
int nXPos, // x-coordinate of pixel
int nYPos // y-coordinate of pixel
);
"你的位图.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
if( hbmp == NULL )
return -1; CBitmap m_bmp;
m_bmp.Attach( hbmp );
BITMAP bmp;
m_bmp.GetBitmap(&bmp); CDC dc;
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&m_bmp);
POINT pt;
COLORREF clr; for(int i=0; i<bmp.bmHeight; i++)
{
for(int j=0; j<bmp.bmWidth; j++)
{
pt.x = j;
pt.y = i;
clr = memDC.GetPixel(pt);
}
}