当前位置: 首页>>代码示例>>C++>>正文


C++ Image::DepthBytes方法代码示例

本文整理汇总了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");
}
开发者ID:AntAgna,项目名称:OpenCLIPP,代码行数:27,代码来源:Image.cpp


注:本文中的Image::DepthBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。