IDS peak IPL  v1.3.2
peak_ipl_image_writer.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
17 
18 #include <cstdint>
19 #include <string>
20 
21 namespace peak
22 {
23 namespace ipl
24 {
25 
26 class Image;
27 
34 class ImageWriter final
35 {
36 public:
37  ImageWriter() = delete;
38 
42  struct PNGParameter final
43  {
45  : Quality(100)
46  {}
47  // Compression parameter from 0 to 100 -> 100 means quality level 0 for PNG
48  uint32_t Quality = 100;
49  };
50 
54  struct JPEGParameter final
55  {
57  : Quality(75)
58  {}
59  // Quality parameter from 0 to 100
60  uint32_t Quality = 75;
61  };
62 
85  static void WriteAsBMP(const std::string& filePath, const Image& imageToSave);
86 
111  static void WriteAsPNG(
112  const std::string& filePath, const Image& imageToSave, const PNGParameter& parameter = PNGParameter());
113 
134  static void WriteAsJPG(
135  const std::string& filePath, const Image& imageToSave, const JPEGParameter& parameter = JPEGParameter());
136 
153  static void WriteAsRAW(const std::string& filePath, const Image& imageToSave);
154 
168  static void Write(const std::string& filePath, const Image& imageToSave);
169 };
170 
171 } /* namespace ipl */
172 } /* namespace peak */
173 
175 
176 namespace peak
177 {
178 namespace ipl
179 {
180 inline void ImageWriter::WriteAsBMP(const std::string& filePath, const Image& imageToSave)
181 {
184  ImageBackendAccessor::BackendHandle(imageToSave), filePath.c_str(), filePath.size());
185  });
186 }
187 
189  const std::string& filePath, const Image& imageToSave, const PNGParameter& parameter)
190 {
193  ImageBackendAccessor::BackendHandle(imageToSave), parameter.Quality, filePath.c_str(), filePath.size());
194  });
195 }
196 
198  const std::string& filePath, const Image& imageToSave, const JPEGParameter& parameter)
199 {
202  ImageBackendAccessor::BackendHandle(imageToSave), parameter.Quality, filePath.c_str(), filePath.size());
203  });
204 }
205 
206 inline void ImageWriter::WriteAsRAW(const std::string& filePath, const Image& imageToSave)
207 {
210  ImageBackendAccessor::BackendHandle(imageToSave), filePath.c_str(), filePath.size());
211  });
212 }
213 
214 inline void ImageWriter::Write(const std::string& filePath, const Image& imageToSave)
215 {
218  ImageBackendAccessor::BackendHandle(imageToSave), filePath.c_str(), filePath.size());
219  });
220 }
221 
222 } /* namespace ipl */
223 } /* namespace peak */
uint32_t Quality
Definition: peak_ipl_image_writer.hpp:48
static void WriteAsPNG(const std::string &filePath, const Image &imageToSave, const PNGParameter &parameter=PNGParameter())
Writes the specified image to the filesystem as PNG image.
Definition: peak_ipl_image_writer.hpp:188
Parameter for the PNG write e.g. compression quality.
Definition: peak_ipl_image_writer.hpp:42
static void WriteAsRAW(const std::string &filePath, const Image &imageToSave)
Writes the specified image to the filesystem as a raw binary image.
Definition: peak_ipl_image_writer.hpp:206
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
Writes an image to a file.
Definition: peak_ipl_image_writer.hpp:34
static void WriteAsJPG(const std::string &filePath, const Image &imageToSave, const JPEGParameter &parameter=JPEGParameter())
Writes the specified image to the filesystem as JPEG image.
Definition: peak_ipl_image_writer.hpp:197
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_color_corrector.hpp:30
PEAK_IPL_C_API PEAK_IPL_ImageWriter_WriteAsBMP(PEAK_IPL_IMAGE_HANDLE inputImageHandle, const char *filePath, size_t filePathSize)
Writes an image as BMP image file.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:128
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:37
PEAK_IPL_C_API PEAK_IPL_ImageWriter_WriteAsJPG(PEAK_IPL_IMAGE_HANDLE inputImageHandle, uint32_t quality, const char *filePath, size_t filePathSize)
Writes an image as JPEG image file.
PEAK_IPL_C_API PEAK_IPL_ImageWriter_WriteAsRAW(PEAK_IPL_IMAGE_HANDLE inputImageHandle, const char *filePath, size_t filePathSize)
Writes an image as raw data binary file.
PEAK_IPL_C_API PEAK_IPL_ImageWriter_WriteAsPNG(PEAK_IPL_IMAGE_HANDLE inputImageHandle, uint32_t quality, const char *filePath, size_t filePathSize)
Writes an image as PNG image file.
Parameter for the JPEG write e.g. compression quality.
Definition: peak_ipl_image_writer.hpp:54
JPEGParameter()
Definition: peak_ipl_image_writer.hpp:56
static void Write(const std::string &filePath, const Image &imageToSave)
Writes the specified image to the filesystem. The type is specified by the given file ending in file ...
Definition: peak_ipl_image_writer.hpp:214
PNGParameter()
Definition: peak_ipl_image_writer.hpp:44
static void WriteAsBMP(const std::string &filePath, const Image &imageToSave)
Writes the specified image to the filesystem as BMP image.
Definition: peak_ipl_image_writer.hpp:180
uint32_t Quality
Definition: peak_ipl_image_writer.hpp:60
PEAK_IPL_C_API PEAK_IPL_ImageWriter_Write(PEAK_IPL_IMAGE_HANDLE inputImageHandle, const char *filePath, size_t filePathSize)
Writes an image to file and selects the format by file ending. In case the format has parameters...