IDS peak IPL  v1.9.2
peak_ipl_image_reader.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
18 
19 #include <string>
20 
21 namespace peak
22 {
23 namespace ipl
24 {
25 
26 class Image;
27 
34 class ImageReader final
35 {
36 public:
37  ImageReader() = delete;
38 
54  PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath);
55 
76  PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath, const peak::ipl::PixelFormat& pixelFormat);
77 };
78 
79 inline Image ImageReader::Read(const std::string& filePath)
80 {
81  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
83  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReader_Read(filePath.c_str(), filePath.size(), &outputImageHandle);
84  });
85 
86  return ImageBackendAccessor::CreateImage(outputImageHandle);
87 }
88 
89 inline peak::ipl::Image ImageReader::Read(const std::string& filePath, const PixelFormat& pixelFormat)
90 {
91  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
93  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReaderRead_ReadAsPixelFormat(filePath.c_str(), filePath.size(),
94  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), &outputImageHandle);
95  });
96 
97  return ImageBackendAccessor::CreateImage(outputImageHandle);
98 }
99 
100 } /* namespace ipl */
101 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
#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:22
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.
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:39
Reads an image from a file.
Definition: peak_ipl_image_reader.hpp:34
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:357
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:176
Represents a pixel format and its specific properties.
Definition: peak_ipl_pixel_format.hpp:31