IDS peak IPL v1.11.0
Loading...
Searching...
No Matches
peak_ipl_image_reader.hpp
Go to the documentation of this file.
1
11#pragma once
12
18
19#include <string>
20
21namespace peak
22{
23namespace ipl
24{
25
26class Image;
27
34class ImageReader final
35{
36public:
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
79inline 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
89inline 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 */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:40
Reads an image from a file.
Definition peak_ipl_image_reader.hpp:35
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:79
Represents a pixel format and its specific properties.
Definition peak_ipl_pixel_format.hpp:32
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition peak_ipl_pixel_format.hpp:122
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
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:361
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:180
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:16