自学内容网 自学内容网

GraphicsMagick 的 OpenCL 开发记录(九)

<2022-03-17 Thu>

关于ImageMagick中的number_channels成员(一)

ImageMagicknumber_channels成员出现频率有点高,经调试发现ImageMagick中图片对象初始化时通过调用OpenPixelCache()然后在InitializePixelChannelMap()中设置number_channels的值。这个函数的内部大量使用了GraphicsMagick中没有类型PixelChannelPixelTrait,不太好把它给搬到GraphicsMagick中。

查看PixelChannel的定义发现了它的一个特点是:虽然它是enum类型,但每个成员都被指派了具体的值,且发现有多个成员共用一个值的情况。以此参照仍然没有在GraphicsMagick中找到类似定义,PixelChannel的定义:

typedef enum
{
  UndefinedPixelChannel = 0,
  RedPixelChannel = 0,
  CyanPixelChannel = 0,
  GrayPixelChannel = 0,
  LPixelChannel = 0,
  LabelPixelChannel = 0,
  YPixelChannel = 0,
  aPixelChannel = 1,
  GreenPixelChannel = 1,
  MagentaPixelChannel = 1,
  CbPixelChannel = 1,
  bPixelChannel = 2,
  BluePixelChannel = 2,
  YellowPixelChannel = 2,
  CrPixelChannel = 2,
  BlackPixelChannel = 3,
  AlphaPixelChannel = 4,
  IndexPixelChannel = 5,
  ReadMaskPixelChannel = 6,
  WriteMaskPixelChannel = 7,
  MetaPixelChannel = 8,
  CompositeMaskPixelChannel = 9,
  IntensityPixelChannel = MaxPixelChannels,  /* ???? */
  CompositePixelChannel = MaxPixelChannels,  /* ???? */
  SyncPixelChannel = MaxPixelChannels+1      /* not a real channel */
} PixelChannel;  /* must correspond to ChannelType */

我模仿ImageMagickInitializePixelChannelMap()函数写了calc_image_number_channels(),虽然number_channels的值对于同一张测试图片bg1a.jpg来说均为3,但是在IM中值3显示正确,而在GM3 + 1才能正确,所以我在ComputeResizeImage()中将calc_image_number_channels()的返回值加上了1

number_channels=(cl_uint) calc_image_number_channels(image)+1;

这只是临时方案,估计下面要更改抄过来的kernel函数。

commitcalc number_channels, but need to plus 1 to get correct result


原文地址:https://blog.csdn.net/ftuc5dn/article/details/135710720

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!