本文整理汇总了C++中Image::DepthBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::DepthBytes方法的具体用法?C++ Image::DepthBytes怎么用?C++ Image::DepthBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::DepthBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Error
// ROI Constructor
Image::Image(Image& Img, const SPoint& Offset, const SSize& Size, cl_mem_flags flags)
: Buffer(Img.m_CL, Img,
Offset.Y * Img.Step() + Offset.X * Img.DepthBytes() * Img.NbChannels(), // Calculate offset in bytes
Size.Height * Img.Step() - (Img.Width() - Size.Width) * Img.DepthBytes() * Img.NbChannels(), // Calculate size in bytes
flags,
(size_t&) flags), // Use flags as temporary variable to receive the actual offset value
ImageBase(Img)
{
// Buffer is not always capable of creating a sub-buffer at the offset specified due to memory alignement requirements
// So it may create a buffer that starts ealier than the offset we calculated and thus it will have a bigger size
// So in order to cover the whole ROI, we need to recalculate the size of the image
size_t AskedOffset = Offset.Y * Img.Step() + Offset.X * Img.DepthBytes() * Img.NbChannels();
size_t ActualBufferOffset = size_t(flags);
size_t OffsetDifference = AskedOffset - ActualBufferOffset;
size_t OffsetDiffElements = OffsetDifference / (Img.DepthBytes() * Img.NbChannels());
if (OffsetDiffElements <= Offset.X)
{
m_Img.Width = Size.Width + uint(OffsetDiffElements);
m_Img.Height = Size.Height;
return;
}
// Offset difference covers more than one row - this would be difficult to handle
throw cl::Error(CL_MISALIGNED_SUB_BUFFER_OFFSET, "Unable to reate ROI due to memory alignement requirements");
}