equal
deleted
inserted
replaced
|
1 #include "cache.h" |
|
2 |
|
3 static int pt_cache_new (struct pt_cache **cache_ptr) |
|
4 { |
|
5 struct pt_cache *cache; |
|
6 |
|
7 if ((cache = calloc(1, sizeof(*cache))) == NULL) |
|
8 return -1; |
|
9 |
|
10 // ok |
|
11 *cache_ptr = cache; |
|
12 |
|
13 return 0; |
|
14 } |
|
15 |
|
16 int pt_cache_open (struct pt_cache **cache_ptr, struct pt_image *img, int mode) |
|
17 { |
|
18 struct pt_cache *cache; |
|
19 |
|
20 // alloc |
|
21 if (pt_cache_new(&cache)) |
|
22 return -1; |
|
23 |
|
24 |
|
25 } |
|
26 |
|
27 bool pt_cache_fresh (struct pt_cache *cache) |
|
28 { |
|
29 // TODO: stat + mtime |
|
30 return false; |
|
31 } |
|
32 |
|
33 /** |
|
34 * Create a new cache file, open it, and write out the header. |
|
35 */ |
|
36 static int pt_cache_create (struct pt_cache *cache, struct pt_cache_header *header) |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 int pt_cache_update_png (struct pt_cache *cache, png_structp png, png_infop info) |
|
42 { |
|
43 struct pt_cache_header header; |
|
44 |
|
45 memset(&header, 0, sizeof(header)); |
|
46 |
|
47 // fill in basic info |
|
48 header->width = png_get_image_width(png, info); |
|
49 header->height = png_get_image_height(png, info); |
|
50 header->bit_depth = png_get_bit_depth(png, info); |
|
51 header->color_type = png_get_color_type(png, info); |
|
52 |
|
53 // fill in other info |
|
54 header->row_bytes = png_get_rowbytes(png, info); |
|
55 } |