24 #include <fvwidgets/image_display.h> 26 #include <fvwidgets/sdl_keeper.h> 29 #include <core/exception.h> 30 #include <fvutils/color/conversions.h> 31 #include <fvutils/color/yuv.h> 52 ImageDisplay::ImageDisplay(
unsigned int width,
unsigned int height,
const char* title)
55 SDLKeeper::init(SDL_INIT_VIDEO);
56 if (title) SDL_WM_SetCaption (title, NULL);
61 int bpp = SDL_VideoModeOK(_width, _height, 16, SDL_ANYFORMAT);
62 _surface = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE | SDL_ANYFORMAT);
64 throw Exception(
"SDL: cannot create surface");
68 _overlay = SDL_CreateYUVOverlay(width, height, SDL_UYVY_OVERLAY, _surface);
83 ImageDisplay::~ImageDisplay()
87 SDL_FreeYUVOverlay(_overlay);
88 SDL_FreeSurface(_surface);
99 ImageDisplay::show(colorspace_t colorspace,
unsigned char *buffer)
101 SDL_LockYUVOverlay(_overlay);
102 convert(colorspace, YUV422_PACKED, buffer, _overlay->pixels[0], _width, _height);
103 SDL_UnlockYUVOverlay(_overlay);
104 SDL_DisplayYUVOverlay(_overlay, _rect);
112 ImageDisplay::show(
unsigned char *yuv422_planar_buffer)
114 SDL_LockYUVOverlay(_overlay);
116 yuv422planar_to_yuv422packed(yuv422_planar_buffer, _overlay->pixels[0],
119 SDL_UnlockYUVOverlay(_overlay);
120 SDL_DisplayYUVOverlay(_overlay, _rect);
127 ImageDisplay::process_events(
unsigned int max_num_events)
129 unsigned int proc = 0;
131 while ( (proc++ < max_num_events) && (SDL_PollEvent(&event)) ) {
142 ImageDisplay::loop_until_quit()
147 if ( SDL_WaitEvent(&event) ) {
148 switch (event.type) {
153 if ( (event.key.keysym.sym == SDLK_ESCAPE) ||
154 (event.key.keysym.sym == SDLK_q) ) {
Fawkes library namespace.
Base class for exceptions in Fawkes.