Image Viewer Implementation

Design

imgvwrflowchart.jpg

Implementation

Firstly, an MPI environment is initialized using the MPI_Init() method. The nodes are instructed to display the image on their display screens by setting the DISPLAY environment variable to the value ‘localhost:0.0’ or simply ‘:0.0’. The X server running on the nodes allow the server to authenticate by disabling access control, which can be done by issuing the command ‘xhost +server’.

if(rank!=0){
      sprintf(buf,":0.0",proc_name);
    setenv("DISPLAY",buf, 1);
   }

The most important function is the one which is used to display the image on the tiled display. It scales the image taking into account the image’s width and height and the maximum resolution of the tiled display wall, thus maintaining the aspect ratio of the image. The offset variable defines the thickness of the edge of the screen. It is used to compensate the part of the image compromised due to the edge of the screen.

zoom_image=IMG_Load(curr_image->filename);
   img_aspect_ratio = (zoom_image->w)/(zoom_image->h);
   scr_aspect_ratio = (VIDEO_WIDTH)/(VIDEO_HEIGHT);

   if(img_aspect_ratio==scr_aspect_ratio){
      if(rank==0){
         xfactor=(double)zoom_image->w/(double)(VIDEO_WIDTH);
         yfactor=(double)zoom_image->h/(double)(VIDEO_HEIGHT);
      } else {
         xfactor=(double)zoom_image->w/((double)(VIDEO_WIDTH*2)+2*offset);
         yfactor=(double)zoom_image->h/((double)(VIDEO_HEIGHT*2)+2*offset);
      }
      temp_surface=zoomSurface(
                    zoom_image,
                    (double)1/xfactor,
                    (double)1/yfactor,SMOOTHING_ON);
   }else{
      if(abs(zoom_image->w-VIDEO_WIDTH)>(abs(zoom_image->h-VIDEO_HEIGHT))){
         if(rank==0){
            xfactor=(double)zoom_image->w/(double)(VIDEO_WIDTH);
            yfactor=xfactor;
         } else {
            xfactor=(double)
              zoom_image->h/((double)(VIDEO_HEIGHT*2)+2*offset);
            yfactor=xfactor;
         }
      } else {
         if(rank==0){
            yfactor=(double)zoom_image->h/(double)(VIDEO_HEIGHT);
            xfactor=yfactor;
         }else{
            yfactor=(double)
            zoom_image->w/((double)(VIDEO_WIDTH*2)+2*offset);
            xfactor=yfactor;
         }
      }
   }

Once the scaling is done, the image is split into four equal parts based on the rank of each node. The image surface is blitted on to the screen surface and then flipped to display the final image on the screen.

image_panel = SDL_SetVideoMode(
                        VIDEO_WIDTH, VIDEO_HEIGHT, 
                        temp_surface->format->BitsPerPixel,
                        SDL_FULLSCREEN | SDL_HWSURFACE);
   switch(rank){
      case 0:
         rect.x=0;
         rect.y=0;
         rect.w=(temp_surface->w);
         rect.h=(temp_surface->h);
         SDL_BlitSurface(temp_surface,0,image_panel,0);
         break;
      case 1:
         rect.x=0;
         rect.y=0;
         rect.w=(VIDEO_WIDTH)+offset;
      rect.h=(VIDEO_HEIGHT)+offset;
         SDL_BlitSurface(temp_surface,&rect,image_panel,0);
         break;
      case 2:
         rect.x=(VIDEO_WIDTH)+(2*offset);rect.y=0;
         rect.w=(VIDEO_WIDTH);rect.h=(VIDEO_HEIGHT)+offset;
         SDL_BlitSurface(temp_surface,&rect,image_panel,0);
         break;
      case 3:
         rect.x=(VIDEO_WIDTH)+(2*offset);rect.y=(VIDEO_HEIGHT)+(2*offset);
         rect.w=(VIDEO_WIDTH);rect.h=(VIDEO_HEIGHT);
         SDL_BlitSurface(temp_surface,&rect,image_panel,0);
         break;
      case 4:
         rect.x=0;rect.y=(VIDEO_HEIGHT)+(2*offset);
         rect.w=(VIDEO_WIDTH);rect.h=(VIDEO_HEIGHT);
         SDL_BlitSurface(temp_surface,&rect,image_panel,0);
         break;
   }
   SDL_Flip(image_panel);
}

A graphical user interface (GUI) has been developed for the tiled display image viewer considering the ease of usability. The GUI interface enables the user to interact effortlessly with the system. The graphical user interface is invoked on the server node and the client nodes wait for a signal from the server to display the image or the video. This increases the interaction with the image viewer as the image viewing options like zooming, panning and rotation can be done in real-time using the GUI interface.

agar-logo.gif

The GUI interface was built using the AGAR toolkit, a graphics toolkit based on SDL. (http://hypertriton.com/agar/)
The Agar-GUI toolkit provides a set of widgets and an internal window system for applications that require window system independence.
Our primary reasons behind using the AGAR toolkit to develop the GUI was

  • Portability

AGAR offers good portability unlike other toolkits like Gtk+, Qt which face a certain amount of portability issues across different desktop systems.

  • Integration

Since AGAR is based on SDL, it couples well with the image viewer and video viewer applications written in SDL.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.