将SDL_Surface转换为IplImage

时间:2012-07-10 07:06:19

标签: opencv sdl

我将 IplImage 转换为 SDL_Surface
引用此link

SDL_Surface *single_channel_ipl_to_surface (IplImage *opencvimg)
{
    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom((void*)opencvimg->imageData,
                           opencvimg->width,
                           opencvimg->height,
                           opencvimg->depth*opencvimg->nChannels,
                           opencvimg->widthStep,
                           1, 1, 1 ,0);
    return surface;
}

如何将 SDL_Surface 转换为 IplImage

1 个答案:

答案 0 :(得分:0)

您需要从SDL_Surface检索4条信息,因此请调查API以了解如何检索:

  • 图片的尺寸(宽度/高度);
  • 图片的位深度;
  • 频道数;
  • 图片的数据(像素);

之后,您可create an IplImage from scratch cvCreateImageHeader()后跟cvSetData()