IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_image_reader.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
13
14#include <string>
15
16namespace peak
17{
18namespace ipl
19{
20
21class Image;
22
30class ImageReader final
31{
32public:
33 ImageReader() = delete;
34
50 PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath);
51
72 PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath, const peak::ipl::PixelFormat& pixelFormat);
73};
74
75inline Image ImageReader::Read(const std::string& filePath)
76{
77 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
79 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReader_Read(filePath.c_str(), filePath.size(), &outputImageHandle);
80 });
81
82 return ImageBackendAccessor::CreateImage(outputImageHandle);
83}
84
85inline peak::ipl::Image ImageReader::Read(const std::string& filePath, const PixelFormat& pixelFormat)
86{
87 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
89 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReaderRead_ReadAsPixelFormat(filePath.c_str(), filePath.size(),
90 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), &outputImageHandle);
91 });
92
93 return ImageBackendAccessor::CreateImage(outputImageHandle);
94}
95
96} /* namespace ipl */
97} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:42
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:75
Represents a pixel format and its specific properties.
Definition peak_ipl_pixel_format.hpp:30
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition peak_ipl_pixel_format.hpp:120
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:284
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
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.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:402
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:170
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.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:11