Theory
The main motive for development of a cluster-based image viewer is to display high-resolution large-scale images containing millions of pixels. These images cannot be viewed on a single workstation PC without loss of details or loss of context. Tiled display image viewer offers a cheaper alternative when compared to high-definition display systems developed for this purpose.
Algorithm
Step 1
Initialize MPI.
RANK = rank of the node in the cluster.Initialize SDL.
VIDEO_WIDTH = maximum resolution width of the display.
VIDEO_HEIGHT = the maximum resolution height of the display.
Set the video mode to VIDEO_WIDTH x VIDEO_HEIGHTStep 2
If RANK = 0 (Server Node)
Initialize the Agar GUI subsystem.
Display the GUI on the server node.Step 3
Displaying Image -
Open the image file and read the following image file information -
Depth (in bits/pixel).
Width (in pixels) - IMAGE->W.
Height (in pixels) – IMAGE->H.Offset (in pixels) – Thickness of the display monitor boundary.
Calculate the coordinates for the image divisions based on the rank.
If RANK = 1
X = 0 W = (VIDEO_WIDTH)+Offset
Y = 0 H = (VIDEO_HEIGHT)+OffsetIf RANK = 2
X = (VIDEO_WIDTH)+(2*Offset)
Y = 0
W = (VIDEO_WIDTH)
H = (VIDEO_HEIGHT)+OffsetIf RANK = 3
X = (VIDEO_WIDTH)+(2*Offset)
Y = (VIDEO_HEIGHT)+(2*Offset)
W = (VIDEO_WIDTH)+Offset
H = (VIDEO_HEIGHT)If RANK = 4
X = 0
Y = (VIDEO_HEIGHT)+(2*Offset)
W = (VIDEO_WIDTH)
H = (VIDEO_HEIGHT)Step 4
Zoom in / Zoom out image to maintain the aspect ratioIMG_AR = IMAGE->W / IMAGE-> H
SCRN_AR = VIDEO_WIDTH / VIDEO_HEIGHTIf (IMAGE->W - VIDEO_WIDTH) > (IMAGE->H – VIDEO_HEIGHT)
xfactor = IMAGE->H / (VIDEO_HEIGHT)
yfactor = xfactorElse
yfactor = IMAGE->W / (VIDEO_WIDTH)
xfactor = yfactorZoom image with factor xfactor & yfactor.
Step 5
Synchronization of tile nodes.Wait for blit signal from the server.
If (signal is received)
Blit image on the screen surface.Wait for keyboard events.
Step 6
Finalize SDL
Finalize MPI
Exit.