GetPixel 读出的不是全1就是全0?

lzjcqu 2008-12-16 02:26:55
pDC->SetPixel(0,0,RGB(112,111,111));
current=pDC->GetPixel(0,0);
明明才设置的颜色,为什么读出的current不等于RGB(112,111,111)
GetPixel 读出转换成二进制的不是全1就是全0?
...全文
151 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hi_dzj 2011-03-27
  • 打赏
  • 举报
回复
同问,还有为什么我画橡皮筋类CRectTracker,反向画矩形时GetPixel所获取的像素值不是我鼠标当前所指的像素值??? 那个值好像闪了一下又变成RGB(0,0,0)了??
我是苦力 2008-12-17
  • 打赏
  • 举报
回复
如果你的图片是1bit色深的,不管你怎么设都是都是0 和 1 的。
所以换一个图片看看,先看图片的属性,找个24bit的来试试先。
lzjcqu 2008-12-16
  • 打赏
  • 举报
回复
没有不成功,取到了,只是取到的结果不对
lzjcqu 2008-12-16
  • 打赏
  • 举报
回复
是啊
e01620230 2008-12-16
  • 打赏
  • 举报
回复
current 这个是COLORREF 格式的吗?
shhpj11 2008-12-16
  • 打赏
  • 举报
回复
不懂,up
qqlpp 2008-12-16
  • 打赏
  • 举报
回复
不懂,up
vcPlayer 2008-12-16
  • 打赏
  • 举报
回复
CDC::SetPixel
COLORREF SetPixel( int x, int y, COLORREF crColor );

COLORREF SetPixel( POINT point, COLORREF crColor );

Return Value

An RGB value for the color that the point is actually painted. This value can be different from that specified by crColor if an approximation of that color is used. If the function fails (if the point is outside the clipping region), the return value is -1.

CDC::GetPixel
COLORREF GetPixel( int x, int y ) const;

COLORREF GetPixel( POINT point ) const;

Return Value

For either version of the function, an RGB color value for the color of the given point. It is -1 if the coordinates do not specify a point in the clipping region.


检查一下为什么设置不成功。
linglongyouzhi 2008-12-16
  • 打赏
  • 举报
回复
不要打断点看,用trace看看,应该是没有问题的

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧