qa_image_display.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <fvwidgets/image_display.h>
00027 #include <fvwidgets/sdl_keeper.h>
00028 #include <fvutils/readers/fvraw.h>
00029
00030 #include <cstdio>
00031 #include <cstdlib>
00032 #include <unistd.h>
00033
00034 #include <SDL.h>
00035
00036 int
00037 main(int argc, char **argv)
00038 {
00039 const char *img_file;
00040 if ( argc > 1 ) {
00041 img_file = argv[1];
00042 } else {
00043 printf("Usage: %s <raw image file>\n", argv[0]);
00044 exit(-1);
00045 }
00046
00047
00048 FvRawReader *fvraw = new FvRawReader(img_file);
00049 unsigned char *buffer = malloc_buffer(fvraw->colorspace(),
00050 fvraw->pixel_width(), fvraw->pixel_height());
00051
00052 fvraw->set_buffer(buffer);
00053 fvraw->read();
00054
00055 ImageDisplay *display = new ImageDisplay(fvraw->pixel_width(), fvraw->pixel_height());
00056 display->show(fvraw->colorspace(), buffer);
00057
00058 SDLKeeper::init(SDL_INIT_EVENTTHREAD);
00059
00060 bool quit = false;
00061 while (! quit) {
00062 SDL_Event event;
00063 if ( SDL_WaitEvent(&event) ) {
00064 switch (event.type) {
00065 case SDL_QUIT:
00066 quit = true;
00067 break;
00068 default:
00069 break;
00070 }
00071 }
00072 }
00073
00074 delete display;
00075 free(buffer);
00076 delete(fvraw);
00077
00078 SDLKeeper::quit();
00079
00080 return 0;
00081 }
00082
00083
00084
00085