3#include "../global.hpp"
5#include "../_decl/decl_vpat.hpp"
6#include "../_decl/decl_linear_access.hpp"
7#include "../_decl/decl_array_access.hpp"
9#include "../_decl/decl_image_plane.hpp"
11#include "../plane.hpp"
18 template <class PLANE_T, std::enable_if_t<PlaneTraits<PLANE_T>::HasVpat,
int>>
19 LinearAccessData LinearAccessData::FromPlaneImpl(
const PLANE_T &plane)
noexcept
23 {PlaneTrait::GetWidth(plane), PlaneTrait::GetHeight(plane)},
24 PlaneTrait::GetDataType(plane));
27 template <class PLANE_T, std::enable_if_t<!PlaneTraits<PLANE_T>::HasVpat,
int>>
28 LinearAccessData LinearAccessData::FromPlaneImpl(
const PLANE_T &plane)
noexcept
31 const std::intptr_t xInc = PlaneTrait::GetXInc(plane);
32 const int width = PlaneTrait::GetWidth(plane);
33 if (PlaneTrait::GetRank(plane) == 1)
34 return LinearAccessData{PlaneTrait::GetBasePtr(plane), xInc, xInc * width, width};
35 return LinearAccessData{PlaneTrait::GetBasePtr(plane), xInc, PlaneTrait::GetYInc(plane), width};
39 template <
class PLANE_T>
44 return FromPlaneImpl(plane);
50 auto vpat = access.VpatPtr();
51 if (!vpat || size.Width() <= 0 || size.Height() <= 0)
54 if (bytesPerPixel == 0)
57 auto lastXEntry = vpat[0].OffsetX;
58 const auto xInc = size.Width() == 1 ? bytesPerPixel : vpat[1].OffsetX - lastXEntry;
59 auto lastYEntry = vpat[0].OffsetY;
60 const auto yInc = size.Height() == 1 ? xInc * size.Width() : vpat[1].OffsetY - lastYEntry;
61 const auto basePtr = access.BasePtr() + vpat->OffsetY + vpat->OffsetX;
64 for (
int i = 1; i < max; ++i)
66 auto current = vpat[i];
69 if ((current.OffsetX - lastXEntry) != xInc)
71 lastXEntry = current.OffsetX;
73 if (i < size.Height())
75 if ((current.OffsetY - lastYEntry) != yInc)
77 lastYEntry = current.OffsetY;
85 template <
class PLANE_T>
97 if (access.XInc() > 0 && access.XInc() * size.Width() == access.YInc())
98 return ArrayAccess{access.BasePtr(), access.XInc(), size.Width()};
110 return LinearAccessData{basePtr_ + newAoi.Top() * inc_ * width_ + newAoi.Left() * inc_, inc_, inc_ * width_,
static ArrayAccess FromVpat(const Vpat &access, Size2D< int > size, DataType dataType) noexcept
Tries to get a valid ArrayAccess trait from the given VPAT access.
Definition detail_plane_access.hpp:103
static ArrayAccess FromLinearAccess(const LinearAccessData &access, Size2D< int > size) noexcept
Tries to get a valid ArrayAccess trait from the given access.
Definition detail_plane_access.hpp:93
LinearAccessData NewMoved(const Rect< int > newAoi) const noexcept
Creates a new, moved linear access object.
Definition detail_plane_access.hpp:108
static ArrayAccess FromPlane(const PLANE_T &plane) noexcept
Tries to get a valid ArrayAccess trait from the given plane.
Definition detail_plane_access.hpp:86
Data type description for an image plane.
Definition data_type.hpp:23
Linear access properties.
Definition decl_linear_access.hpp:25
LinearAccessData() noexcept
Creates a default linear access data set.
static LinearAccessData FromPlane(const PLANE_T &plane) noexcept
Tries to get a valid LinearAccessData from the given plane.
Definition detail_plane_access.hpp:40
static LinearAccessData FromVpat(const Vpat &access, Cvb::Size2D< int > size, Cvb::DataType dataType) noexcept
Tries to get a valid LinearAccessData trait from the given vpat.
Definition detail_plane_access.hpp:47
Rectangle object.
Definition rect.hpp:24
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
Virtual Pixel Access Table.
Definition decl_vpat.hpp:24
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Definition global.hpp:1080