File: img.h

package info (click to toggle)
cbflib 0.9.6%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 56,196 kB
  • sloc: ansic: 103,920; python: 4,552; sh: 3,032; makefile: 1,822; yacc: 659; f90: 210; xml: 210; cpp: 58; java: 16
file content (137 lines) | stat: -rw-r--r-- 4,959 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

  /* image object v. 1.1 */

#ifndef IMG_H
#define IMG_H

#ifdef __cplusplus

extern "C" {
        
#endif

#include <stdio.h>

    
#define img_BAD_ARGUMENT    0x0001
#define img_BAD_ALLOC       0x0002
#define img_BAD_OPEN        0x0004
#define img_BAD_READ        0x0008
#define img_BAD_FORMAT      0x0010
#define img_BAD_FIELD       0x0020
#define img_BAD_WRITE       0x0040
    
    /* Tag */
    
    typedef struct
    {
        char                 *tag;
        char                 *data;
    }
    img_tag;
    
    
    /* Image */
    
    typedef struct
    {
        int                   tags;
        img_tag              *tag;
        
        int                   size [2];  /* size[0] = columns, size[1] = rows */
        int					rowmajor;  /* set to 1 for row major, 0 for column major */
        int                  *image;
    }
    img_object;
    
    typedef img_object *img_handle;
    
    
    /* Functions */
    
#define img_pixel(img,x,y)                                              \
          (((img)->rowmajor)?                                           \
          (((img)->image) [((img)->size) [0] * (int) (y) + (int) (x)]) :\
          (((img)->image) [((img)->size) [1] * (int) (x) + (int) (y)]))
#define img_pixelptr(img,x,y)                                              \
             (((img)->rowmajor)?                                           \
            &(((img)->image) [((img)->size) [0] * (int) (y) + (int) (x)]) :\
            &(((img)->image) [((img)->size) [1] * (int) (x) + (int) (y)]))
#define img_columns(img)    ((img)->size [0])
#define img_rows(img)       ((img)->size [1])
    
    int         img_swap_i4 (int i4);
    float       img_float_i4 (int i4,
                              int VAX);
    int         img_read_i4 (FILE *file,
                             int *i4);
    int         img_read_smvheader (img_handle img,
                                    FILE *file);
    int         img_read_smvdata (img_handle img,
                                  FILE *file);
    int         img_read_smv (img_handle img,
                              const char *name);
    int         img_write_smv (img_object   *img,
                       const char   *name,
                       unsigned int  bits);
    int         img_read_mar300header (img_handle img,
                                       FILE *file,
                                       int *org_data);
    int         img_read_mar300data (img_handle img,
                                     FILE *file,
                                     int *org_data);
    int         img_read_mar300 (img_handle img,
                                 const char *name);
    int         img_read_mar345header (img_handle img,
                                       FILE *file,
                                       int *org_data);
    int         img_read_mar345data (img_handle img,
                                     FILE *file,
                                     int *org_data);
    int         img_read_mar345 (img_handle img,
                                 const char *name);
    int         img_get_tags (img_handle img);
    int         img_delete_fieldnumber (img_handle img, int x);
    
    img_handle  img_make_handle    ( void );
    int         img_read           (img_handle img,
                                    const char *name);
    int         img_free_handle    (img_handle img);
    int         img_delete_field   (img_handle img,
                                    const char *tag);
    const char *img_get_field      (img_handle img,
                                    const char *tag);
    int         img_get_next_field (img_handle img,
                                    const char **tag,
                                    const char **data,
                                    int *index);
    int         img_set_field      (img_handle img,
                                    const char *tag,
                                    const char *data);
    double      img_get_number     (img_handle img,
                                    const char *tag);
    int         img_set_number     (img_handle img,
                                    const char *tag,
                                    const char *format,
                                    double data);
    int         img_get_pixel      (img_handle img,
                                    int x,
                                    int y);
    int         img_set_pixel      (img_handle img,
                                    int x,
                                    int y,
                                    int data);
    int         img_set_dimensions (img_handle img,
                                    int columns,
                                    int rows);
    int         img_get_dimension  (img_handle img,
                                    int dimension);
    
#ifdef __cplusplus
    
}

#endif

#endif /* IMG_H */