您的位置:首页 > 其它

SDL 1.2版本显示YUYV422数据

2015-01-26 13:46 337 查看
/*
* 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐