使用单个nChannal将IplImage转换为SDL_Surface

时间:2018-11-19 14:22:18

标签: c opencv sdl sdl-2 iplimage

如何将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());
}

0 个答案:

没有答案