IDS peak IPL v1.17.2
Loading...
Searching...
No Matches
peak_ipl_image_reader.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
18
19#include <string>
20
21namespace peak
22{
23namespace ipl
24{
25
26class Image;
27
35class ImageReader final
36{
37public:
38 ImageReader() = delete;
39
55 PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath);
56
77 PEAK_IPL_NO_DISCARD static Image Read(const std::string& filePath, const peak::ipl::PixelFormat& pixelFormat);
78};
79
80inline Image ImageReader::Read(const std::string& filePath)
81{
82 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
84 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReader_Read(filePath.c_str(), filePath.size(), &outputImageHandle);
85 });
86
87 return ImageBackendAccessor::CreateImage(outputImageHandle);
88}
89
90inline peak::ipl::Image ImageReader::Read(const std::string& filePath, const PixelFormat& pixelFormat)
91{
92 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
94 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageReaderRead_ReadAsPixelFormat(filePath.c_str(), filePath.size(),
95 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat.PixelFormatName()), &outputImageHandle);
96 });
97
98 return ImageBackendAccessor::CreateImage(outputImageHandle);
99}
100
101} /* namespace ipl */
102} /* namespace peak */
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:47
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:80
Represents a pixel format and its specific properties.
Definition peak_ipl_pixel_format.hpp:35
peak::ipl::PixelFormatName PixelFormatName() const
Returns the name of the pixel format as enum value.
Definition peak_ipl_pixel_format.hpp:125
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:289
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
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:405
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
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