| 1 | /* |
| 2 | * pnmio.h |
| 3 | * I/O interface to the Portable Any Map (PNM) image format. |
| 4 | * Version 0.4, Release 2025-May-07. |
| 5 | * |
| 6 | * Copyright (C) 2002-2025 Cosmin Truta. |
| 7 | * |
| 8 | * Use, modification and distribution are subject |
| 9 | * to the Boost Software License, Version 1.0. |
| 10 | * See the accompanying file LICENSE_BSL_1_0.txt |
| 11 | * or visit https://www.boost.org/LICENSE_1_0.txt |
| 12 | * |
| 13 | * SPDX-License-Identifier: BSL-1.0 |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | #ifndef PNMIO_H_ |
| 18 | #define PNMIO_H_cxx . . $ `third_party/pnmio/pnmio.h:18:9`! |
| 19 | |
| 20 | #include <stddef.h> |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | |
| 28 | /* |
| 29 | * PNM format codes. |
| 30 | */ |
| 31 | enumcxx . . $ $anonymous_type_13c48408ecc95125_0# |
| 32 | { |
| 33 | PNM_P1cxx . . $ PNM_P1. = 1, /* plain PBM */ |
| 34 | PNM_P2cxx . . $ PNM_P2. = 2, /* plain PGM */ |
| 35 | PNM_P3cxx . . $ PNM_P3. = 3, /* plain PPM */ |
| 36 | PNM_P4cxx . . $ PNM_P4. = 4, /* raw PBM */ |
| 37 | PNM_P5cxx . . $ PNM_P5. = 5, /* raw PGM */ |
| 38 | PNM_P6cxx . . $ PNM_P6. = 6, /* raw PPM */ |
| 39 | PNM_P7cxx . . $ PNM_P7. = 7 /* PAM (only partially implemented) */ |
| 40 | }; |
| 41 | |
| 42 | |
| 43 | /* |
| 44 | * PNM info structure. |
| 45 | */ |
| 46 | typedef struct pnm_structcxx . . $ pnm_struct# |
| 47 | { |
| 48 | unsigned int formatcxx . . $ pnm_struct#format.; |
| 49 | unsigned int depthcxx . . $ pnm_struct#depth.; |
| 50 | unsigned int widthcxx . . $ pnm_struct#width.; |
| 51 | unsigned int heightcxx . . $ pnm_struct#height.; |
| 52 | unsigned int maxvalcxx . . $ pnm_struct#maxval.; |
| 53 | } pnm_structcxx . . $ pnm_struct#; |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | * PNM input functions. |
| 58 | */ |
| 59 | int pnm_fget_headercxx . . $ pnm_fget_header(9bcad1d1c3342fed).(pnm_structcxx . . $ pnm_struct# *pnm_ptr, FILEcxx . . $ FILE# *stream); |
| 60 | int pnm_fget_valuescxx . . $ pnm_fget_values(552de6dcb89e7f8a).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, |
| 61 | unsigned int *sample_values, |
| 62 | unsigned int num_rows, |
| 63 | FILEcxx . . $ FILE# *stream); |
| 64 | int pnm_fget_bytescxx . . $ pnm_fget_bytes(e0e7c29afa84996c).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, |
| 65 | unsigned char *sample_bytes, |
| 66 | size_t sample_size, |
| 67 | unsigned int num_rows, |
| 68 | FILEcxx . . $ FILE# *stream); |
| 69 | |
| 70 | |
| 71 | /* |
| 72 | * PNM output functions. |
| 73 | */ |
| 74 | int pnm_fput_headercxx . . $ pnm_fput_header(3346212fee16b45c).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, FILEcxx . . $ FILE# *stream); |
| 75 | int pnm_fput_valuescxx . . $ pnm_fput_values(33c046a80e55a1c3).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, |
| 76 | const unsigned int *sample_values, |
| 77 | unsigned int num_rows, |
| 78 | FILEcxx . . $ FILE# *stream); |
| 79 | int pnm_fput_bytescxx . . $ pnm_fput_bytes(4cf41f321688feec).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, |
| 80 | const unsigned char *sample_bytes, |
| 81 | size_t sample_size, |
| 82 | unsigned int num_rows, |
| 83 | FILEcxx . . $ FILE# *stream); |
| 84 | |
| 85 | |
| 86 | /* |
| 87 | * PNM utility functions. |
| 88 | */ |
| 89 | int pnm_is_validcxx . . $ pnm_is_valid(e5c06f7168a162ac).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr); |
| 90 | size_t pnm_raw_sample_sizecxx . . $ pnm_raw_sample_size(7ca4f236b4cb3eac).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr); |
| 91 | size_t pnm_mem_sizecxx . . $ pnm_mem_size(8442c759a8830b27).(const pnm_structcxx . . $ pnm_struct# *pnm_ptr, |
| 92 | size_t sample_size, |
| 93 | unsigned int num_rows); |
| 94 | |
| 95 | |
| 96 | /* |
| 97 | * PNM limits. |
| 98 | */ |
| 99 | #define PNM_BYTE_MAXcxx . . $ `third_party/pnmio/pnmio.h:99:9`! 0xffU |
| 100 | #define PNM_VALUE_MAXcxx . . $ `third_party/pnmio/pnmio.h:100:9`! 0xffffffffU |
| 101 | #define PNM_SIZE_MAXcxx . . $ `third_party/pnmio/pnmio.h:101:9`! (~0U) |
| 102 | #if PNM_SIZE_MAXcxx . . $ `third_party/pnmio/pnmio.h:101:9`! < 0xffffffffUL |
| 103 | #error This software requires a 32-bit machine (or bigger). |
| 104 | #endif |
| 105 | |
| 106 | |
| 107 | #ifdef __cplusplus |
| 108 | } /* extern "C" */ |
| 109 | #endif |
| 110 | |
| 111 | #endif /* PNMIO_H_ */ |