BufferOut.Pixels[][]输出的是什么?该如何解决
BufferOut.Pixels[][]输出的是什么?
下面是代码,问一下如何能够得到每个点的rgb值并保存下来?又怎么进行修改?希望说具体点,谢谢啦
ImageSize.cx=InBuffer.GetWidth();
ImageSize.cy=InBuffer.GetHeight();
m_Bmp.DeleteObject();
m_Bmp.CreateCompatibleBitmap(GetDC(),ImageSize.cx,ImageSize.cy);
//加载bitmap到本地文件夹下
InBuffer.ToBitmap(m_Bmp);
CRect ImageRect(0,0,ImageSize.cx,ImageSize.cy);
CPaintDC dc(this);
CDC AnotherDC;
AnotherDC.CreateCompatibleDC(&dc);
AnotherDC.SelectObject(m_Bmp);
///////////////////////////////////////////////////////////////////////////
/*if ((fp = fopen("points.txt", "w+b")) == NULL)
{
MessageBox("打开文件出错!");
}
fwrite(fp,4,"%d\n",**p);
fclose(fp);*/
/////////////////////////////////////////////////////////////////////////////
int Width = BufferOut.GetWidth();
int Height = BufferOut.GetHeight();
FILE *fp = NULL;
CString Str;
Str.Format("CaptureFrame:%d",FrameNo);
AnotherDC.TextOut(0,0,Str);
AnotherDC.MoveTo(0,0);
AnotherDC.LineTo(Width,Height);
if ((fp = fopen("points.txt", "w+")) == NULL)
{
MessageBox("打开文件出错!");
}
p = new int *[Width];
for(int i = 0; i < Width; i ++)
p[i] = new int[Height];
//取得每一像素点的值
if(m_Pauseframe.EnableWindow)
{
for ( int x = 0; x < Width; x ++ )[color=#FF0000][/color]
for( int y = 0; y < Height; y ++ )
{
**p=BufferOut.Pixels[ x ][ y ] ;
fprintf(fp, "%04x\n",**p );// 对齐的十六进制
// fprintf(fp, "%d\n",**p );//一串数据
}
fclose(fp);
CString strName;
strName.Format( "%i.bmp", FrameNo );
SaveBmp((HBITMAP)(m_Bmp),strName);
}
FrameNo ++;
InvalidateRect(ImageRect,FALSE);
------解决方案--------------------
p是int *的数组
每个int *又new了heigth个元素
**p就是动态new出的2维数组中的某一元素,他存储了对应的pixel的值
------解决方案--------------------
看你的代码里面,应该是rgb的值。
下面是代码,问一下如何能够得到每个点的rgb值并保存下来?又怎么进行修改?希望说具体点,谢谢啦
ImageSize.cx=InBuffer.GetWidth();
ImageSize.cy=InBuffer.GetHeight();
m_Bmp.DeleteObject();
m_Bmp.CreateCompatibleBitmap(GetDC(),ImageSize.cx,ImageSize.cy);
//加载bitmap到本地文件夹下
InBuffer.ToBitmap(m_Bmp);
CRect ImageRect(0,0,ImageSize.cx,ImageSize.cy);
CPaintDC dc(this);
CDC AnotherDC;
AnotherDC.CreateCompatibleDC(&dc);
AnotherDC.SelectObject(m_Bmp);
///////////////////////////////////////////////////////////////////////////
/*if ((fp = fopen("points.txt", "w+b")) == NULL)
{
MessageBox("打开文件出错!");
}
fwrite(fp,4,"%d\n",**p);
fclose(fp);*/
/////////////////////////////////////////////////////////////////////////////
int Width = BufferOut.GetWidth();
int Height = BufferOut.GetHeight();
FILE *fp = NULL;
CString Str;
Str.Format("CaptureFrame:%d",FrameNo);
AnotherDC.TextOut(0,0,Str);
AnotherDC.MoveTo(0,0);
AnotherDC.LineTo(Width,Height);
if ((fp = fopen("points.txt", "w+")) == NULL)
{
MessageBox("打开文件出错!");
}
p = new int *[Width];
for(int i = 0; i < Width; i ++)
p[i] = new int[Height];
//取得每一像素点的值
if(m_Pauseframe.EnableWindow)
{
for ( int x = 0; x < Width; x ++ )[color=#FF0000][/color]
for( int y = 0; y < Height; y ++ )
{
**p=BufferOut.Pixels[ x ][ y ] ;
fprintf(fp, "%04x\n",**p );// 对齐的十六进制
// fprintf(fp, "%d\n",**p );//一串数据
}
fclose(fp);
CString strName;
strName.Format( "%i.bmp", FrameNo );
SaveBmp((HBITMAP)(m_Bmp),strName);
}
FrameNo ++;
InvalidateRect(ImageRect,FALSE);
------解决方案--------------------
p是int *的数组
每个int *又new了heigth个元素
**p就是动态new出的2维数组中的某一元素,他存储了对应的pixel的值
------解决方案--------------------
看你的代码里面,应该是rgb的值。