具体代码如下:
Bitmap mybitmap(L"myimage2.jpg");
m_nBmpWidth =mybitmap.GetWidth();
m_nBmpHeight=mybitmap.GetHeight();
m_nBuf_Len_TwoDim = m_nBmpHeight*m_nBmpWidth;
p_image_Color_buf=new BYTE[3*m_nBuf_Len_TwoDim];
memset(m_image_buf,0,m_nBuf_Len_TwoDim);
memset(p_image_Color_buf,0,3*m_nBuf_Len_TwoDim);
Color mycolor;
int R, G, B;
for(int i = 0; i < m_nBmpHeight;i++)
{
for(int j = 0; j < m_nBmpWidth; j++)//x--width
{
mybitmap.GetPixel(j,i,&mycolor);//获得像素值
R=mycolor.GetR();
G=mycolor.GetG();
B=mycolor.GetB();
*(p_image_Color_buf+(599-i)*m_nBmpWidth*3+j*3)=B;
*(p_image_Color_buf+(599-i)*m_nBmpWidth*3+j*3+1)=G;
*(p_image_Color_buf+(599-i)*m_nBmpWidth*3+j*3+2)=R;
}//for(j)
m_pBmpInfo =GetBItmapInfo_Color(m_nBmpWidth, m_nBmpHeight); //生成位图文件头信息
m_Two_Image = Bitmap::FromBITMAPINFO(m_pBmpInfo,p_image_Color_buf);//由位图文件头和已读取的图片像素重新生成位图
原始图片:
后生成的位图:
哪位高手懂这个呀。给指点指点吧!小妹不胜感激!