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 |