4楼,我编译是没有问题的 3楼,不赞同你的说法,我这个int* 型的p_image里是有数据的最后我想办法调成功了,但还是有疑问我新加了COLORREF变量, COLORREF * mycolor=new COLORREF[height*width]; //下面循环是将p_image中数据赋给COLORREF *型的mycolor for(int i=0;i<height;i++) { for(int j=0;j<width;j++) { mycolor[i*pDoc->width+j]=RGB(p_image[i*pDoc->width*3+j*3+2], p_image[i*pDoc->width*3+j*3+1], p_image[i*pDoc->width*3+j*3+0]); } } //利用COLORREF *型的mycolor作为函数CreateBitmap的最后一个变量 mybit.CreateBitmap(pDoc->width,pDoc->height,1,32,mycolor);//这里最后一个参数用了COLORREF指针型最让我纳闷的是,为什么我int *型的p_image就不行,COLORREF *型的就可以呢?附: MSDN上是这样说的 CBitmap::CreateBitmap BOOL CreateBitmap( int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits );最后一个参数lpBits Points to a short-integer array that contains the initial bitmap bit values. If it is NULL, the new bitmap is left uninitialized. 老实说,没看出来,一定要用COLORREF型啊
3楼,不赞同你的说法,我这个int* 型的p_image里是有数据的最后我想办法调成功了,但还是有疑问我新加了COLORREF变量,
COLORREF * mycolor=new COLORREF[height*width];
//下面循环是将p_image中数据赋给COLORREF *型的mycolor
for(int i=0;i<height;i++)
{
for(int j=0;j<width;j++)
{
mycolor[i*pDoc->width+j]=RGB(p_image[i*pDoc->width*3+j*3+2],
p_image[i*pDoc->width*3+j*3+1],
p_image[i*pDoc->width*3+j*3+0]);
}
}
//利用COLORREF *型的mycolor作为函数CreateBitmap的最后一个变量
mybit.CreateBitmap(pDoc->width,pDoc->height,1,32,mycolor);//这里最后一个参数用了COLORREF指针型最让我纳闷的是,为什么我int *型的p_image就不行,COLORREF *型的就可以呢?附:
MSDN上是这样说的
CBitmap::CreateBitmap
BOOL CreateBitmap( int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits );最后一个参数lpBits
Points to a short-integer array that contains the initial bitmap bit values. If it is NULL, the new bitmap is left uninitialized.
老实说,没看出来,一定要用COLORREF型啊