Easy3D 2.5.3
image_io.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_FILEIO_IMAGE_IO_H
28#define EASY3D_FILEIO_IMAGE_IO_H
29
30#include <vector>
31#include <string>
32
33
34namespace easy3d {
35
36
39 class ImageIO
40 {
41 public:
86 static bool load(
87 const std::string& file_name,
88 std::vector<unsigned char>& data,
89 int& width,
90 int& height,
91 int& channels,
92 int requested_channels = 0,
93 bool flip_vertically = true
94 );
95
115 static bool save(
116 const std::string& file_name,
117 const std::vector<unsigned char>& data,
118 int width,
119 int height,
120 int channels,
121 bool flip_vertically = false
122 );
123
124 };
125
126
127 namespace io {
128
138 bool save_ppm(const std::string& file_name, const std::vector<unsigned char>& bits, int width, int height);
139
143 bool save_bmp(const std::string& file_name, const std::vector<unsigned char>& bits, int width, int height);
144
148 bool save_tga(const std::string& file_name, const std::vector<unsigned char>& bits, int width, int height);
149
150 }
151
152
153} // namespace easy3d
154
155
156#endif // EASY3D_FILEIO_IMAGE_IO_H
Implementation of file input/output operations for images.
Definition: image_io.h:40
static bool load(const std::string &file_name, std::vector< unsigned char > &data, int &width, int &height, int &channels, int requested_channels=0, bool flip_vertically=true)
Load image data from a file. The following formats are supported JPG/JPEG, PNG, BMP,...
Definition: image_io.cpp:41
static bool save(const std::string &file_name, const std::vector< unsigned char > &data, int width, int height, int channels, bool flip_vertically=false)
Write image data into a file. The following formats are supported JPG/JPEG, PNG, BMP,...
Definition: image_io.cpp:68
bool save_tga(const std::string &file_name, const std::vector< unsigned char > &bits, int width, int height)
Definition: image_io.cpp:190
bool save_bmp(const std::string &file_name, const std::vector< unsigned char > &bits, int width, int height)
Definition: image_io.cpp:137
bool save_ppm(const std::string &file_name, const std::vector< unsigned char > &bits, int width, int height)
Definition: image_io.cpp:114
Definition: collider.cpp:182