src/lib/cache.c
changeset 18 f92a24ab046e
parent 17 baf3fe7c6354
child 34 a387bc77ad52
equal deleted inserted replaced
17:baf3fe7c6354 18:f92a24ab046e
   395     }
   395     }
   396 
   396 
   397 
   397 
   398     // move from .tmp to .cache
   398     // move from .tmp to .cache
   399     if ((err = pt_cache_create_done(cache)))
   399     if ((err = pt_cache_create_done(cache)))
       
   400         // XXX: pt_cache_abort?
   400         return err;
   401         return err;
   401 
   402 
   402     // done!
   403     // done!
   403     return 0;
   404     return 0;
   404 }
   405 }
   494 
   495 
   495 int pt_cache_tile_png (struct pt_cache *cache, png_structp png, png_infop info, const struct pt_tile_info *ti)
   496 int pt_cache_tile_png (struct pt_cache *cache, png_structp png, png_infop info, const struct pt_tile_info *ti)
   496 {
   497 {
   497     int err;
   498     int err;
   498 
   499 
       
   500     // ensure open
       
   501     if ((err = pt_cache_open(cache)))
       
   502         return err;
       
   503 
   499     // check within bounds
   504     // check within bounds
   500     if (ti->x >= cache->header->width || ti->y >= cache->header->height)
   505     if (ti->x >= cache->header->width || ti->y >= cache->header->height)
   501         // completely outside
   506         // completely outside
   502         RETURN_ERROR(PT_ERR_TILE_CLIP);
   507         RETURN_ERROR(PT_ERR_TILE_CLIP);
   503 
   508 
   504     // ensure open
       
   505     if ((err = pt_cache_open(cache)))
       
   506         return err;
       
   507 
       
   508     // set basic info
   509     // set basic info
   509     png_set_IHDR(png, info, ti->width, ti->height, cache->header->bit_depth, cache->header->color_type,
   510     png_set_IHDR(png, info, ti->width, ti->height, cache->header->bit_depth, cache->header->color_type,
   510             PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT
   511             PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT
   511     );
   512     );
   512 
   513