不知道如何使用图像的字节*? [英] Don't know how to use byte* of a image?
问题描述
我读了这篇文章: http://www.runicsoft.com/bmp.cpp [ ^ ]。但是我不知道如何使用它。
我每次都想要鼠标按下我的控件,它将返回int格式:RGB(R,G,B)。
但是当我在容器C#中使用它时,它工作不正确。
我的代码:
I read this toturial:http://www.runicsoft.com/bmp.cpp[^]. But i don't know how to use it.
I want everytime Left mouse down on my control, it will return int format: "RGB(R,G,B)".
But when i use it in container C#,it worked incorrectly.
My code:
void CLoadImageXCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
int x, y;
long size;
BYTE* Buffer = LoadBMP ( &x, &y, &size, "myBMP.bmp" );
BYTE* aRGB =ConvertBMPToRGBBuffer(Buffer,x,y);
delete[] Buffer;
int index=point.x*x+point.y;
CString str;
COLORREF clr= RGB(aRGB[index],aRGB[index+1],aRGB[index+2]);
str.Format("!!!RGB(%d,%d,%d)",GetRValue(clr),GetGValue(clr),GetBValue(clr));
delete[] aRGB;
myClick(str);
InvalidateControl();
COleControl::OnLButtonDown(nFlags, point);
}
请给我帮助。
我是新手。
提前致谢。
Please sone help me.
I am newbie.
Thanks in advance.
推荐答案
很抱歉在这里询问。但我现在没时间了。
Sorry for asking here. But i have no time now.
CString myfuntion(HWND hWnd,CDC* dc,CPoint point)
{
CString str;
CBitmap bmpCOM;
BITMAP bm;
bmpCOM.LoadBitmap(IDB_ROKU);
bmpCOM.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
dcMem.SelectObject(bmpCOM);
HDC hdcMem=dcMem;
COLORREF clr= GetPixel(hdcMem,point.x,point.y);
str.Format("W:%d H:%d {X:%d Y=%d}RGB(%d,%d,%d)",bm.bmWidth,bm.bmHeight,point.x,point.y,GetRValue(clr),GetGValue(clr),GetBValue(clr));
return str;
}
这是我写的代码。
但是当我用它时,Y轴不正确。
而不是y = 10,它在临时DC中变成y = 15.
我试图解决3天但没办法。
请大家BEG。
这就是我生命的终点。
this is the code i wrote by my mind.
But when i used it, the Y axis is not right.
Instead of y=10, it became y=15 in temp DC.
I tried to solve 3 days but have no way.
PLEASE I BEG everyone.
this is where my life is end.
这篇关于不知道如何使用图像的字节*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!