python/pypngtile.pyx
changeset 57 06258920cec8
parent 34 a387bc77ad52
child 78 a3aaf5c23454
equal deleted inserted replaced
56:d5e3089906da 57:06258920cec8
    27     enum pt_cache_status :
    27     enum pt_cache_status :
    28         PT_CACHE_ERROR
    28         PT_CACHE_ERROR
    29         PT_CACHE_FRESH
    29         PT_CACHE_FRESH
    30         PT_CACHE_NONE
    30         PT_CACHE_NONE
    31         PT_CACHE_STALE
    31         PT_CACHE_STALE
       
    32         PT_CACHE_INCOMPAT
    32 
    33 
    33     struct pt_image_info :
    34     struct pt_image_info :
    34         size_t width, height
    35         size_t img_width, img_height
       
    36         int img_mtime, cache_mtime, cache_version
       
    37         size_t img_bytes, cache_bytes
       
    38         size_t cache_blocks
       
    39 
       
    40     struct pt_image_params :
       
    41         int background_color[4]
    35 
    42 
    36     struct pt_tile_info :
    43     struct pt_tile_info :
    37         size_t width, height
    44         size_t width, height
    38         size_t x, y
    45         size_t x, y
    39         int zoom
    46         int zoom
    40         
    47 
    41     int pt_image_open (pt_image **image_ptr, pt_ctx *ctx, char *png_path, int cache_mode)
    48     int pt_image_open (pt_image **image_ptr, pt_ctx *ctx, char *png_path, int cache_mode)
    42     int pt_image_info_func "pt_image_info" (pt_image *image, pt_image_info **info_ptr)
    49     int pt_image_info_func "pt_image_info" (pt_image *image, pt_image_info **info_ptr)
    43     int pt_image_status (pt_image *image)
    50     int pt_image_status (pt_image *image)
    44     int pt_image_update (pt_image *image)
    51     int pt_image_update (pt_image *image, pt_image_params *params)
    45     int pt_image_tile_file (pt_image *image, pt_tile_info *info, stdio.FILE *out)
    52     int pt_image_tile_file (pt_image *image, pt_tile_info *info, stdio.FILE *out)
    46     int pt_image_tile_mem (pt_image *image, pt_tile_info *info, char **buf_ptr, size_t *len_ptr)
    53     int pt_image_tile_mem (pt_image *image, pt_tile_info *info, char **buf_ptr, size_t *len_ptr)
    47     void pt_image_destroy (pt_image *image)
    54     void pt_image_destroy (pt_image *image)
    48 
    55 
    49     char* pt_strerror (int err)
    56     char* pt_strerror (int err)
    51 OPEN_UPDATE = PT_OPEN_UPDATE
    58 OPEN_UPDATE = PT_OPEN_UPDATE
    52 CACHE_ERROR = PT_CACHE_ERROR
    59 CACHE_ERROR = PT_CACHE_ERROR
    53 CACHE_FRESH = PT_CACHE_FRESH
    60 CACHE_FRESH = PT_CACHE_FRESH
    54 CACHE_NONE = PT_CACHE_NONE
    61 CACHE_NONE = PT_CACHE_NONE
    55 CACHE_STALE = PT_CACHE_STALE
    62 CACHE_STALE = PT_CACHE_STALE
       
    63 CACHE_INCOMPAT = PT_CACHE_INCOMPAT
    56 
    64 
    57 class Error (BaseException) :
    65 class Error (BaseException) :
    58     pass
    66     pass
    59 
    67 
    60 cdef int trap_err (char *op, int ret) except -1 :
    68 cdef int trap_err (char *op, int ret) except -1 :
    77         
    85         
    78         trap_err("pt_image_info",
    86         trap_err("pt_image_info",
    79             pt_image_info_func(self.image, &image_info)
    87             pt_image_info_func(self.image, &image_info)
    80         )
    88         )
    81 
    89 
    82         return (image_info.width, image_info.height)
    90         return (image_info.img_width, image_info.img_height)
    83     
    91     
    84     def status (self) :
    92     def status (self) :
    85         return trap_err("pt_image_status", 
    93         return trap_err("pt_image_status", 
    86             pt_image_status(self.image)
    94             pt_image_status(self.image)
    87         )
    95         )
    88     
    96     
       
    97     # XXX: support params
    89     def update (self) :
    98     def update (self) :
    90         trap_err("pt_image_update", 
    99         trap_err("pt_image_update", 
    91             pt_image_update(self.image)
   100             pt_image_update(self.image, NULL)
    92         )
   101         )
    93 
   102 
    94     def tile_file (self, size_t width, size_t height, size_t x, size_t y, int zoom, object out) :
   103     def tile_file (self, size_t width, size_t height, size_t x, size_t y, int zoom, object out) :
    95         cdef stdio.FILE *outf
   104         cdef stdio.FILE *outf
    96         cdef pt_tile_info ti
   105         cdef pt_tile_info ti