Debian Codegraph @

src/thirdparty/VLFeat/pgm.h

raw
1 /** @file pgm.h
2 ** @brief Portable graymap format (PGM) parser
3 ** @author Andrea Vedaldi
4 **/
5
6 /*
7 Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
8 All rights reserved.
9
10 This file is part of the VLFeat library and is made available under
11 the terms of the BSD license (see the COPYING file).
12 */
13
14 #ifndef VL_PGM_H
15 #define VL_PGM_H
16
17 #include "generic.h"
18 #include "mathop.h"
19 #include <stdio.h>
20
21 /** @name PGM parser error codes
22 ** @{ */
23 #define VL_ERR_PGM_INV_HEAD 101 /**< Invalid PGM header section. */
24 #define VL_ERR_PGM_INV_META 102 /**< Invalid PGM meta section. */
25 #define VL_ERR_PGM_INV_DATA 103 /**< Invalid PGM data section.*/
26 #define VL_ERR_PGM_IO 104 /**< Generic I/O error. */
27 /** @} */
28
29 /** @brief PGM image meta data
30 **
31 ** A PGM image is a 2-D array of pixels of width #width and height
32 ** #height. Each pixel is an integer one or two bytes wide, depending
33 ** whether #max_value is smaller than 256.
34 **/
35
36 typedef struct _VlPgmImage
37 {
38 vl_size width ; /**< image width. */
39 vl_size height ; /**< image height. */
40 vl_size max_value ; /**< pixel maximum value (<= 2^16-1). */
41 vl_bool is_raw ; /**< is RAW format? */
42 } VlPgmImage ;
43
44 /** @name Core operations
45 ** @{ */
46 VL_EXPORT int vl_pgm_extract_head (FILE *f, VlPgmImage *im) ;
47 VL_EXPORT int vl_pgm_extract_data (FILE *f, VlPgmImage const *im, void *data) ;
48 VL_EXPORT int vl_pgm_insert (FILE *f,
49 VlPgmImage const *im,
50 void const*data ) ;
51 VL_EXPORT vl_size vl_pgm_get_npixels (VlPgmImage const *im) ;
52 VL_EXPORT vl_size vl_pgm_get_bpp (VlPgmImage const *im) ;
53 /** @} */
54
55 /** @name Helper functions
56 ** @{ */
57 VL_EXPORT int vl_pgm_write (char const *name,
58 vl_uint8 const *data,
59 int width, int height) ;
60 VL_EXPORT int vl_pgm_write_f (char const *name,
61 float const *data,
62 int width, int height) ;
63 VL_EXPORT int vl_pgm_read_new (char const *name,
64 VlPgmImage *im,
65 vl_uint8 **data) ;
66 VL_EXPORT int vl_pgm_read_new_f (char const *name,
67 VlPgmImage *im,
68 float **data) ;
69
70 /** @} */
71
72 /* VL_PGM_H */
73 #endif