⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_layer.cpp

📁 ARM交叉编译工具链
💻 CPP
字号:
/*
  * this src is used for testing the v4l and the sdl .
  * Beside this,it provides a simple wrap of v4l and sdl .
  * You can use it any where,but should keep this header.
  * Any suggestion is appreicated.
  *
  *	Tianjin University , China.
  *	
  *	vinqosky@gmail.com
  */

#include "sdl_layer.h"

int CSDLDisplay::init(int width, int height)
{
	if(SDL_Init(SDL_INIT_VIDEO)<0)
	{
		//ERROR
		return -1;
	}

	m_video_info = SDL_GetVideoInfo();
	m_screen = SDL_SetVideoMode(width,height,32,SDL_SWSURFACE|SDL_ASYNCBLIT);
	m_width = width;
	m_height = height;
	m_dst_rect.x = 0;
	m_dst_rect.y = 0;
	m_dst_rect.w = m_screen->w;
	m_dst_rect.h = m_screen->h;
	m_image = SDL_CreateYUVOverlay(width,height,SDL_YV12_OVERLAY,m_screen);

	return 1;
}

void CSDLDisplay::closeIt()
{
	SDL_FreeYUVOverlay(m_image);
	SDL_FreeSurface(m_screen);
	SDL_Quit();
}

void CSDLDisplay::display(unsigned char * ybuf, unsigned char * ubuf, unsigned char * vbuf)
{
	int ysize = m_width*m_height;
	int uvsize = ysize/4;

	SDL_LockYUVOverlay(m_image);
	memcpy(m_image->pixels[0],ybuf,ysize);
	memcpy(m_image->pixels[1],vbuf,uvsize);
	memcpy(m_image->pixels[2],ubuf,uvsize);
	SDL_DisplayYUVOverlay(m_image,&m_dst_rect);
	SDL_UnlockYUVOverlay(m_image);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -