24#include <core/exception.h>
25#include <fvutils/color/conversions.h>
26#include <fvutils/color/yuv.h>
27#include <fvwidgets/image_display.h>
28#include <fvwidgets/sdl_keeper.h>
52 SDL_WM_SetCaption(title, NULL);
57 int bpp = SDL_VideoModeOK(_width, _height, 16, SDL_ANYFORMAT);
58 _surface = SDL_SetVideoMode(width, height, bpp, SDL_HWSURFACE | SDL_ANYFORMAT);
60 throw Exception(
"SDL: cannot create surface");
64 _overlay = SDL_CreateYUVOverlay(width, height, SDL_UYVY_OVERLAY, _surface);
82 SDL_FreeYUVOverlay(_overlay);
83 SDL_FreeSurface(_surface);
95 SDL_LockYUVOverlay(_overlay);
96 convert(colorspace, YUV422_PACKED, buffer, _overlay->pixels[0], _width, _height);
97 SDL_UnlockYUVOverlay(_overlay);
98 SDL_DisplayYUVOverlay(_overlay, _rect);
107 SDL_LockYUVOverlay(_overlay);
109 yuv422planar_to_yuv422packed(yuv422_planar_buffer, _overlay->pixels[0], _width, _height);
111 SDL_UnlockYUVOverlay(_overlay);
112 SDL_DisplayYUVOverlay(_overlay, _rect);
121 unsigned int proc = 0;
123 while ((proc++ < max_num_events) && (SDL_PollEvent(&event))) {
138 if (SDL_WaitEvent(&event)) {
139 switch (event.type) {
140 case SDL_QUIT: quit =
true;
break;
142 if ((event.key.keysym.sym == SDLK_ESCAPE) || (event.key.keysym.sym == SDLK_q)) {
Base class for exceptions in Fawkes.
~ImageDisplay()
Destructor.
ImageDisplay(unsigned int width, unsigned int height, const char *title=0)
Constructor.
void loop_until_quit()
Process SDL events until quit.
void show(colorspace_t colorspace, unsigned char *buffer)
Show image from given colorspace.
void process_events(unsigned int max_num_events=10)
Process a few SDL events.
static void quit() noexcept
Conditionally quit SDL.
static void init(unsigned int flags)
Init SDL.
Fawkes library namespace.