SDL 1.2版本显示YUYV422数据

/*
 * 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工程源代码地址




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值