如何将IpLImage转换为SDL_Surface。
我使用此post
来转换具有8个nChannel的图像,并且效果很好,但是当我尝试对单个nChannel的图像进行转换时,它将在控制台上显示以下消息:
Depth 8, nChannels 1, pitch 640
Unable to convert the IplImage image ! SDL Error: Unknown pixel format
这是我使用的代码:
int pitch = colored_capture->nChannels * colored_capture->width;
printf("Depth %d, nChannels %d, pitch %d\n", colored_capture->depth,
colored_capture->nChannels, pitch);
surface_1 = SDL_CreateRGBSurfaceFrom((void*)colored_capture->imageData,
colored_capture->width,
colored_capture->height,
colored_capture->depth * colored_capture->nChannels,
colored_capture->widthStep,
0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface_1 == NULL)
{
fprintf ( stderr ,"Unable to convert the IplImage image ! SDL
Error: %s \n", SDL_GetError());
}