GraphicsMagick 的 OpenCL 开发记录(十)
<2022-03-18 Fri>
关于gpuSupportedResizeWeighting()
的代码能否省略
在ImageMagick
的AccelerateResizeImage()
函数中有这样的一段代码被注释掉了:
// if ((gpuSupportedResizeWeighting(GetResizeFilterWeightingType(
// resizeFilter)) == MagickFalse) ||
// (gpuSupportedResizeWeighting(GetResizeFilterWindowWeightingType(
// resizeFilter)) == MagickFalse))
// return((Image *) NULL);
我认为这段代码可以省略,因为它的目的就是为了检查ImageMagick
的ResizeFilter
类型中的ResizeWeightingFunctionType
类型的成员值:
struct _ResizeFilter
{
double
(*filter)(const double,const ResizeFilter *),
(*window)(const double,const ResizeFilter *),
support, /* filter region of support - the filter support limit */
window_support, /* window support, usally equal to support (expert only) */
scale, /* dimension scaling to fit window support (usally 1.0) */
blur, /* x-scale (blur-sharpen) */
coefficient[7]; /* cubic coefficents for BC-cubic filters */
ResizeWeightingFunctionType
filterWeightingType,
windowWeightingType;
size_t
signature;
};
是否在supportedResizeWeighting
数组中:
static const ResizeWeightingFunctionType supportedResizeWeighting[] =
{
BoxWeightingFunction,
TriangleWeightingFunction,
HannWeightingFunction,
HammingWeightingFunction,
BlackmanWeightingFunction,
CubicBCWeightingFunction,
SincWeightingFunction,
SincFastWeightingFunction,
LastWeightingFunction
};
很明显这个数组就是ImageMagick
支持GPU
的窗函数集合。在GraphicsMagick
中我只在ResizeImage()
函数中找到相近的定义:
static const FilterInfo
filters[SincFilter+1] =
{
{ Box, 0.0 },
{ Box, 0.0 },
{ Box, 0.5 },
{ Triangle, 1.0 },
{ Hermite, 1.0 },
{ Hanning, 1.0 },
{ Hamming, 1.0 },
{ Blackman, 1.0 },
{ Gaussian, 1.25 },
{ Quadratic, 1.5 },
{ Cubic, 2.0 },
{ Catrom, 2.0 },
{ Mitchell, 2.0 },
{ Lanczos, 3.0 },
{ BlackmanBessel, 3.2383 },
{ BlackmanSinc, 4.0 }
};
明显可见,GraphicsMagick
中处理相对于ImageMagick
简单多了,所以上面的代码我仍然保持它被注释状态。
原文地址:https://blog.csdn.net/ftuc5dn/article/details/135712324
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!