5#include "../_decl/decl_wrapped_image.hpp"
6#include "../_decl/decl_image_plane.hpp"
8#include "../_decl/decl_vpat.hpp"
15 inline std::unique_ptr<WrappedImage> WrappedImage::FromArray(
const IArray &array)
17 if (
typeid(array) ==
typeid(Cvb::Plane))
19 const auto &plane =
dynamic_cast<const Cvb::Plane &
>(array);
20 if (plane.Rank() != 2)
21 throw std::runtime_error(
"currently only two dimensional planes can be wrapped by an image");
23 auto basePtr = plane.BasePtr();
24 auto xInc = plane.Increment(0);
25 auto yInc = plane.Increment(1);
26 auto dataType = plane.DataType();
27 auto width = plane.Length(0);
28 auto height = plane.Length(1);
29 auto bufferSize = width * height * dataType.BytesPerPixel();
31 return FromGreyPixels(
reinterpret_cast<void *
>(basePtr), bufferSize, width, height, dataType,
32 static_cast<int>(xInc),
static_cast<int>(yInc));
36 const auto &imagePlane =
dynamic_cast<const ImagePlane &
>(array);
37 const auto &image = imagePlane.Parent();
38 auto linearAccess = imagePlane.LinearAccess();
39 auto dataType = imagePlane.DataType();
40 auto width = image.Width();
41 auto height = image.Width();
42 auto bufferSize = width * height * dataType.BytesPerPixel();
44 return FromGreyPixels(
reinterpret_cast<void *
>(linearAccess.BasePtr()), bufferSize, width, height, dataType,
45 static_cast<int>(linearAccess.XInc()),
static_cast<int>(linearAccess.YInc()));
Array interface.
Definition iarray.hpp:16
static std::unique_ptr< WrappedImage > FromGreyPixels(void *buffer, int bufferSize, int width, int height, DataType dataType, int pixelStride, int lineStride)
Wraps, without copying, the given monochrome pixel buffer in an image.
Definition decl_wrapped_image.hpp:46
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17