8.9 Presentations

Some file formats, such as PDF can be used as ‘presentations’, where pages are displayed as a slideshows - a form of poor man’s PowerPoint if you will. Essentially each page contains a record that says how long it should be displayed for before transitioning to the next page with a given graphical effect.

The core MuPDF library is never responsible for actually presenting a page to the user, so it is therefore not possible to expect it to cope with handling all the work required by such transitions.

What it can do is to help in 2 particular areas. Firstly, it can provide some functions to aid the caller in the task of querying the transitions required. Secondly, it can help in providing some helper functions to generate bitmaps of various stages of common transitions.

8.9.1 Querying

We define a structure type to hold the details of arbitrary transitions, together with some opaque state:

enum { 
   FZ_TRANSITION_NONE = 0, /* aka R or REPLACE */ 
   FZ_TRANSITION_SPLIT, 
   FZ_TRANSITION_BLINDS, 
   FZ_TRANSITION_BOX, 
   FZ_TRANSITION_WIPE, 
   FZ_TRANSITION_DISSOLVE, 
   FZ_TRANSITION_GLITTER, 
   FZ_TRANSITION_FLY, 
   FZ_TRANSITION_PUSH, 
   FZ_TRANSITION_COVER, 
   FZ_TRANSITION_UNCOVER, 
   FZ_TRANSITION_FADE 
}; 
 
typedef struct fz_transition_s 
{ 
   int type; 
   float duration; /* Effect duration (seconds) */ 
 
   /* Parameters controlling the effect */ 
   int vertical; /* 0 or 1 */ 
   int outwards; /* 0 or 1 */ 
   int direction; /* Degrees */ 
   /* Potentially more to come */ 
 
   /* State variables for use of the transition code */ 
   int state0; 
   int state1; 
} fz_transition;

Armed with such a structure, we can call a function to get it filled out:

/* 
   fz_page_presentation: Get the presentation details for a given page. 
 
   transition: A pointer to a transition struct to fill out. 
 
   duration: A pointer to a place to set the page duration in seconds. 
   Will be set to 0 if no transition is specified for the page. 
 
   Returns: a pointer to the transition structure, or NULL if there is no 
   transition specified for the page. 
*/ 
fz_transition *fz_page_presentation(fz_context *ctx, fz_page *page, fz_transition *transition, float *duration);

This structure is defined to be sufficient to encapsulate the currently defined PDF transition types; it may be extended in future if other formats require more expressiveness.

Callers are free to directly implement their transitions using the information herein, or else they can make use of a helper function.

8.9.2 Helper functions

Details of a helpful routine for displaying some of these transitions can be found in chapter 37 Transitions.