File: puzzle_p.h

package info (click to toggle)
libpuzzle 0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 2,092 kB
  • sloc: sh: 9,723; ansic: 1,811; makefile: 977; php: 269; sql: 148
file content (67 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __PUZZLE_P_H__
#define __PUZZLE_P_H__ 1

#include <math.h>
#include <gd.h>

typedef struct PuzzleView_ {
    unsigned int width;
    unsigned int height;
    size_t sizeof_map;
    unsigned char *map;
} PuzzleView;

typedef struct PuzzleAvgLvls_ {
    unsigned int lambdas;
    size_t sizeof_lvls;
    double *lvls;
} PuzzleAvgLvls;

typedef enum PuzzleImageTypeCode_ {
    PUZZLE_IMAGE_TYPE_ERROR, PUZZLE_IMAGE_TYPE_UNKNOWN, PUZZLE_IMAGE_TYPE_JPEG,
        PUZZLE_IMAGE_TYPE_GIF, PUZZLE_IMAGE_TYPE_PNG
} PuzzleImageTypeCode;

typedef struct PuzzleImageType_ {
    const size_t sizeof_signature;    
    const unsigned char *signature;
    const PuzzleImageTypeCode image_type_code;
} PuzzleImageType;

#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif

#define PUZZLE_DEFAULT_LAMBDAS 9
#define PUZZLE_DEFAULT_MAX_WIDTH  3000
#define PUZZLE_DEFAULT_MAX_HEIGHT 3000
#define PUZZLE_DEFAULT_NOISE_CUTOFF 2.0
#define PUZZLE_DEFAULT_P_RATIO 2.0
#define PUZZLE_MIN_P 2
#define PUZZLE_PIXEL_FUZZ_SIZE 1
#define PUZZLE_NEIGHBORS 8
#define PUZZLE_MIN_SIZE_FOR_CROPPING 100
#if     PUZZLE_MIN_SIZE_FOR_CROPPING < 4
# error PUZZLE_MIN_SIZE_FOR_CROPPING
#endif
#define PUZZLE_DEFAULT_CONTRAST_BARRIER_FOR_CROPPING 0.05
#define PUZZLE_DEFAULT_MAX_CROPPING_RATIO 0.25
#define PUZZLE_DEFAULT_ENABLE_AUTOCROP 1

#define PUZZLE_VIEW_PIXEL(V, X, Y) (*((V)->map + (V)->width * (Y) + (X)))
#define PUZZLE_AVGLVL(A, X, Y) (*((A)->lvls + (A)->lambdas * (Y) + (X)))

#define PUZZLE_CONTEXT_MAGIC 0xdeadbeef

#ifndef MIN
# define MIN(A, B) ((A) < (B) ? (A) : (B))
#endif
#ifndef MAX
# define MAX(A, B) ((A) > (B) ? (A) : (B))
#endif
#define SUCC(A) ((A) + 1)
#define PRED(A) ((A) - 1)

void puzzle_err_bug(const char * const file, const int line);

#endif