Point Cloud Library (PCL)  1.8.0
libpng_wrapper.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * Author: Julius Kammerl (julius@kammerl.de)
35  */
36 
37 #ifndef __PCL_IO_LIBPNG_WRAPPER__
38 #define __PCL_IO_LIBPNG_WRAPPER__
39 
40 #include <vector>
41 #include <pcl/common/common.h>
42 #include <pcl/common/io.h>
43 
44 namespace pcl
45 {
46  namespace io
47  {
48  /** \brief Encodes 8-bit mono image to PNG format.
49  * \param[in] image_arg input image data
50  * \param[in] width_arg image width
51  * \param[in] height_arg image height
52  * \param[out] pngData_arg PNG compressed image data
53  * \param[in] png_level_arg zLib compression level (default level: -1)
54  * \ingroup io
55  */
56  PCL_EXPORTS void
57  encodeMonoImageToPNG (std::vector<uint8_t>& image_arg,
58  size_t width_arg,
59  size_t height_arg,
60  std::vector<uint8_t>& pngData_arg,
61  int png_level_arg = -1);
62 
63  /** \brief Encodes 16-bit mono image to PNG format.
64  * \param[in] image_arg input image data
65  * \param[in] width_arg image width
66  * \param[in] height_arg image height
67  * \param[out] pngData_arg PNG compressed image data
68  * \param[in] png_level_arg zLib compression level (default level: -1)
69  * \ingroup io
70  */
71  PCL_EXPORTS void
72  encodeMonoImageToPNG (std::vector<uint16_t>& image_arg,
73  size_t width_arg,
74  size_t height_arg,
75  std::vector<uint8_t>& pngData_arg,
76  int png_level_arg = -1);
77 
78  /** \brief Encodes 8-bit RGB image to PNG format.
79  * \param[in] image_arg input image data
80  * \param[in] width_arg image width
81  * \param[in] height_arg image height
82  * \param[out] pngData_arg PNG compressed image data
83  * \param[in] png_level_arg zLib compression level (default level: -1)
84  * \ingroup io
85  */
86  PCL_EXPORTS void
87  encodeRGBImageToPNG (std::vector<uint8_t>& image_arg,
88  size_t width_arg,
89  size_t height_arg,
90  std::vector<uint8_t>& pngData_arg,
91  int png_level_arg = -1);
92 
93  /** \brief Encodes 16-bit RGB image to PNG format.
94  * \param[in] image_arg input image data
95  * \param[in] width_arg image width
96  * \param[in] height_arg image height
97  * \param[out] pngData_arg PNG compressed image data
98  * \param[in] png_level_arg zLib compression level (default level: -1)
99  * \ingroup io
100  */
101  PCL_EXPORTS void
102  encodeRGBImageToPNG (std::vector<uint16_t>& image_arg,
103  size_t width_arg,
104  size_t height_arg,
105  std::vector<uint8_t>& pngData_arg,
106  int png_level_arg = -1);
107 
108  /** \brief Decode compressed PNG to 8-bit image
109  * \param[in] pngData_arg PNG compressed input data
110  * \param[in] imageData_arg image output data
111  * \param[out] width_arg image width
112  * \param[out] heigh_argt image height
113  * \param[out] channels_arg number of channels
114  * \ingroup io
115  */
116  PCL_EXPORTS void
117  decodePNGToImage (std::vector<uint8_t>& pngData_arg,
118  std::vector<uint8_t>& imageData_arg,
119  size_t& width_arg,
120  size_t& heigh_argt,
121  unsigned int& channels_arg);
122 
123  /** \brief Decode compressed PNG to 16-bit image
124  * \param[in] pngData_arg PNG compressed input data
125  * \param[in] imageData_arg image output data
126  * \param[out] width_arg image width
127  * \param[out] height_arg image height
128  * \param[out] channels_arg number of channels
129  * \ingroup io
130  */
131  PCL_EXPORTS void
132  decodePNGToImage (std::vector<uint8_t>& pngData_arg,
133  std::vector<uint16_t>& imageData_arg,
134  size_t& width_arg,
135  size_t& height_arg,
136  unsigned int& channels_arg);
137  }
138 }
139 
140 
141 #endif
142 
PCL_EXPORTS void decodePNGToImage(std::vector< uint8_t > &pngData_arg, std::vector< uint8_t > &imageData_arg, size_t &width_arg, size_t &heigh_argt, unsigned int &channels_arg)
Decode compressed PNG to 8-bit image.
PCL_EXPORTS void encodeMonoImageToPNG(std::vector< uint8_t > &image_arg, size_t width_arg, size_t height_arg, std::vector< uint8_t > &pngData_arg, int png_level_arg=-1)
Encodes 8-bit mono image to PNG format.
Define standard C methods and C++ classes that are common to all methods.
PCL_EXPORTS void encodeRGBImageToPNG(std::vector< uint8_t > &image_arg, size_t width_arg, size_t height_arg, std::vector< uint8_t > &pngData_arg, int png_level_arg=-1)
Encodes 8-bit RGB image to PNG format.