IDS peak IPL  v1.5.0
peak_ipl_image_reader.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
17 
18 #include <string>
19 
20 namespace peak
21 {
22 namespace ipl
23 {
24 
25 class Image;
26 
33 class ImageReader final
34 {
35 public:
36  ImageReader() = delete;
37 
52  static Image Read(const std::string& filePath);
53 
73  static Image Read(const std::string& filePath, const peak::ipl::PixelFormat& pixelFormat);
74 };
75 
76 } /* namespace ipl */
77 } /* namespace peak */
78 
80 
81 namespace peak
82 {
83 namespace ipl
84 {
85 inline Image ImageReader::Read(const std::string& filePath)
86 {
87  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
89  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReader_Read(filePath.c_str(), filePath.size(), &outputImageHandle);
90  });
91 
92  return ImageBackendAccessor::CreateImage(outputImageHandle);
93 }
94 
95 inline peak::ipl::Image ImageReader::Read(const std::string& filePath, const PixelFormat& pixelFormat)
96 {
97  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
99  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReaderRead_ReadAsPixelFormat(filePath.c_str(), filePath.size(),
100  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), &outputImageHandle);
101  });
102 
103  return ImageBackendAccessor::CreateImage(outputImageHandle);
104 }
105 
106 } /* namespace ipl */
107 } /* namespace peak */
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:16
PEAK_IPL_C_API PEAK_IPL_ImageReader_Read(const char *filePath, size_t filePathSize, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Reads an image from a file. Image type is determined by the file ending.
static Image Read(const std::string &filePath)
Returns a new created image which is read from the file with the given file path. ...
Definition: peak_ipl_image_reader.hpp:85
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:37
Reads an image from a file.
Definition: peak_ipl_image_reader.hpp:33
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:267
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition: peak_ipl_pixel_format.hpp:67
PEAK_IPL_C_API PEAK_IPL_ImageReaderRead_ReadAsPixelFormat(const char *filePath, size_t filePathSize, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Reads an image from a file. Image type is determined by the file ending.
int32_t PEAK_IPL_PIXEL_FORMAT
Definition: peak_ipl_backend.h:157
Represents a pixel format and its specific properties.
Definition: peak_ipl_pixel_format.hpp:31