?? sdl_layer.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 + -