SDL 1.2版本显示YUYV422数据

来源:互联网 发布:新华书店淘宝旗舰店 编辑:程序博客网 时间:2024/06/01 20:11
/* * SdlShow.h * *  Created on: 2014-6-1 *      Author: root */#ifndef SDLSHOW_H_#define SDLSHOW_H_#include <SDL/SDL.h>#include <SDL/SDL_thread.h>class SdlShow{public:SdlShow();~SdlShow();bool  SdlInitlib(const int &iWidth ,const int &iHeigth);bool  SdlWindowsShow(unsigned char * pyuv422);private:SDL_Overlay     *Overlay;SDL_Surface     *Surface;SDL_Rect        Rect;SDL_Event       Event;int                    m_iWidth;int                  m_iHeight;};#endif /* SDLSHOW_H_ */
/* * SdlShow.cpp * *  Created on: 2014-6-1 *      Author: root */#include"SdlShow.h"SdlShow::SdlShow(){Overlay = NULL;Surface = NULL;memset(&Rect,0,sizeof(SDL_Rect));memset(&Event,0,sizeof(SDL_Event));m_iWidth = 0;m_iHeight = 0;}SdlShow::~SdlShow(){}bool  SdlShow::SdlInitlib(const int &iWidth ,const int &iHeigth){m_iWidth = iWidth;m_iHeight = iHeigth;if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)){fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); exit(1);}Surface = SDL_SetVideoMode(iWidth, iHeigth, 0, 0);if(!Surface){ perror(" create vide omode error ! \n"); return -1;}Overlay = SDL_CreateYUVOverlay(iWidth,iHeigth,SDL_YUY2_OVERLAY,Surface);Rect.x = 0;Rect.y = 0;Rect.w = iWidth;Rect.h = iHeigth;return true;}bool SdlShow::SdlWindowsShow(unsigned char * pyuv422){SDL_LockYUVOverlay(Overlay);memcpy(Overlay->pixels[0],pyuv422,2*m_iWidth*m_iHeight);SDL_UnlockYUVOverlay(Overlay);SDL_DisplayYUVOverlay(Overlay, &Rect);   return true;}

mian.cpp

YUYV422bufer

SdlShow  oSdlShow;
oSdlShow.SdlInitlib(Width,Height);

oSdlShow.SdlWindowsShow(YUYV422bufer);


linux 下应用SDL1.2和V4L2 获取双目摄像头数据并一起显示eclipse工程源代码地址

http://download.csdn.net/detail/sfe1012/8397383



0 0
原创粉丝点击