11#include "../_cexports/c_img.h"
13#include "../global.hpp"
14#include "../data_type.hpp"
16#include "../_decl/decl_image.hpp"
17#include "../_decl/decl_image_plane.hpp"
18#include "../_decl/decl_device_factory.hpp"
27 return Internal::DoBoolCallObjectOut<Image>(
28 [&](
void *&handle) {
return CVB_CALL_CAPI(LoadImageFileTyped(fileName.c_str(), handle)); });
33 return Internal::DoBoolCallObjectOut<Image>([&](
void *&handle) {
35 numPlanes, width, height,
static_cast<CExports::cvbdatatype_t
>(dataType.
NativeDescriptor()), handle));
39 template <
class RANGE>
43 auto rangeAdapter = MakeRangeAdapter<ImagePlane>(planes);
45 images.reserve(rangeAdapter.Size());
46 for (
const auto &plane : planes)
47 images.emplace_back(plane.Map());
51 template <
class... PLANES>
52 inline typename VarArgRange<std::unique_ptr<Image>,
ImagePlane &&, PLANES...>::type
69 for (
int i = 0; i < planesCount; ++i)
70 planes.push_back(
Plane(i));
78 for (
auto &plane : planes)
79 pixelValues.push_back(plane.GetPixel(position));
87 if (!CVB_CALL_CAPI(WriteImageFileTyped(
Handle(), fileName.c_str())))
88 Utilities::SystemInfo::ThrowLastError();
94 if (!CVB_CALL_CAPI(WriteLossyImageFileTyped(
Handle(), quality, fileName.c_str())))
95 Utilities::SystemInfo::ThrowLastError();
100 return Internal::DoBoolCallObjectOut<Image>([&](
void *&img) {
102 Handle(),
static_cast<CExports::cvbdim_t
>(sourceRect.
Left()),
103 static_cast<CExports::cvbdim_t
>(sourceRect.
Top()),
static_cast<CExports::cvbdim_t
>(sourceRect.
Right()),
104 static_cast<CExports::cvbdim_t
>(sourceRect.
Bottom()),
static_cast<CExports::cvbdim_t
>(targetSize.
Width()),
105 static_cast<CExports::cvbdim_t
>(targetSize.
Height()), img));
111 return Internal::DoBoolCallObjectOut<Image>([&](
void *&img) {
118 return Internal::DoBoolCallObjectOut<Image>(
Data type description for an image plane.
Definition data_type.hpp:23
int NativeDescriptor() const noexcept
Native data type descriptor.
Definition data_type.hpp:312
std::unique_ptr< Image > Map(Rect< int > rect) const
Creates a mapped image of the region of this image.
Definition decl_image.hpp:352
int PlanesCount() const noexcept
Get the number of planes for this image.
Definition decl_image.hpp:247
static TypedRange< std::unique_ptr< Image >, ImagePlane, RANGE >::type FromPlanes(MappingOption mapping, const RANGE &planes)
Create an image that is the result of concatenating a series of input planes.
Definition detail_image.hpp:40
ImagePlane Plane(int plane) const
Indexed access to the individual plane information.
Definition detail_image.hpp:58
void Save(const String &fileName) const
Write the current content of the image into a file.
Definition detail_image.hpp:84
std::unique_ptr< Image > Clone() const
Creates a new image object, that is a copy of the current instance.
Definition detail_image.hpp:116
static TypedRange< std::unique_ptr< Image >, ImagePtr, RANGE >::type FromImages(MappingOption mapping, const RANGE &images)
Create an image that is the result of concatenating a series of input images.
Definition decl_image.hpp:101
std::vector< ImagePlane > Planes() const noexcept
Access all planes for this image.
Definition detail_image.hpp:65
std::vector< double > GetPixel(Point2D< int > position) const
Gets the pixel values for all planes at a give position.
Definition detail_image.hpp:74
static std::unique_ptr< Image > Load(const String &fileName)
Loads an image with the given file name.
Definition detail_image.hpp:25
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:237
static std::unique_ptr< Image > Create(Size2D< int > size, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
Creates an uninitialized image with the given parameters.
Definition decl_image.hpp:75
Image plane information container.
Definition decl_image_plane.hpp:29
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
Rectangle object.
Definition rect.hpp:24
T Bottom() const noexcept
Gets bottom row of the rectangle (still inside the rectangle).
Definition rect.hpp:144
T Top() const noexcept
Gets first row of the rectangle.
Definition rect.hpp:104
T Right() const noexcept
Gets rightmost column of the rectangle (still inside the rectangle).
Definition rect.hpp:124
T Left() const noexcept
Gets first column of the rectangle.
Definition rect.hpp:84
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
cvbbool_t CreateGenericImageDT(cvbval_t NumPlanes, cvbval_t Width, cvbval_t Height, cvbdatatype_t Dataype, IMG &ImageOut)
cvbbool_t CreateImageMap(IMG ImageIn, cvbval_t InLeft, cvbval_t InTop, cvbval_t InRight, cvbval_t InBottom, cvbval_t OutWidth, cvbval_t OutHeight, IMG &ImageOut)
cvbbool_t CreateRotatedImageMap(IMG ImageIn, TVPATRotation Rotation, IMG &ImageOut)
cvbbool_t CreateDuplicateImageEx(IMG ImageIn, IMG &ImageOut)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
RotationMap
Amount of rotation to apply when mapping an image.
Definition global.hpp:377
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
MappingOption
Mapping options when creating a (potentially) mapped image.
Definition global.hpp:361