src/lib/cache.h
changeset 9 a31048ff76a2
parent 8 400ddf1e7aa9
child 10 6806a90d934f
equal deleted inserted replaced
8:400ddf1e7aa9 9:a31048ff76a2
    54     /** Number of png_color entries that follow */
    54     /** Number of png_color entries that follow */
    55     uint16_t num_palette;
    55     uint16_t num_palette;
    56 
    56 
    57     /** Convenience field for number of bytes per row */
    57     /** Convenience field for number of bytes per row */
    58     uint32_t row_bytes;
    58     uint32_t row_bytes;
       
    59     
       
    60     /** Number of bytes per pixel */
       
    61     uint8_t col_bytes;
    59 
    62 
    60     /** Palette entries, up to 256 entries used */
    63     /** Palette entries, up to 256 entries used */
    61     png_color palette[PNG_MAX_PALETTE_LENGTH];
    64     png_color palette[PNG_MAX_PALETTE_LENGTH];
    62 };
    65 };
    63 
    66 
    64 /**
    67 /**
    65  * Construct the image cache info object associated with the given image.
    68  * Construct the image cache info object associated with the given image.
    66  */
    69  */
    67 int pt_cache_open (struct pt_cache **cache_ptr, const char *path, int mode);
    70 int pt_cache_new (struct pt_cache **cache_ptr, const char *path, int mode);
    68 
    71 
    69 /**
    72 /**
    70  * Verify if the cached data eixsts, or has become stale compared to the given original file.
    73  * Verify if the cached data eixsts, or has become stale compared to the given original file.
    71  *
    74  *
    72  * @return one of pt_cache_status; <0 on error, 0 if fresh, >0 otherwise
    75  * @return one of pt_cache_status; <0 on error, 0 if fresh, >0 otherwise
    77  * Update the cache data from the given PNG image.
    80  * Update the cache data from the given PNG image.
    78  */
    81  */
    79 int pt_cache_update_png (struct pt_cache *cache, png_structp png, png_infop info);
    82 int pt_cache_update_png (struct pt_cache *cache, png_structp png, png_infop info);
    80 
    83 
    81 /**
    84 /**
       
    85  * Actually open the existing .cache for use
       
    86  */
       
    87 int pt_cache_open (struct pt_cache *cache);
       
    88 
       
    89 /**
       
    90  * Render out a PNG tile as given, into the established png object, up to (but not including) the png_write_end.
       
    91  *
       
    92  * If the cache is not yet open, this will open it
       
    93  */
       
    94 int pt_cache_tile_png (struct pt_cache *cache, png_structp png, png_infop info, const struct pt_tile_info *ti);
       
    95 
       
    96 /**
    82  * Release all resources associated with the given cache object without any cleanup.
    97  * Release all resources associated with the given cache object without any cleanup.
    83  */
    98  */
    84 void pt_cache_destroy (struct pt_cache *cache);
    99 void pt_cache_destroy (struct pt_cache *cache);
    85 
   100 
    86 #endif
   101 #endif