作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 ios 中构建自定义 warp 内核。
我有这个内核代码
var kernelCode =
" kernel vec2 partialFlip(vec2 center, float width, float height) { " + "\n" +
" vec2 p = destCoord(); " + "\n" +
" float x = width - p.x; " + "\n" +
" float y = height - p.y; " + "\n" +
" return vec2(x, y); } ";
kernel = CIWarpKernel(string: kernelCode);
我想在用户点击图像时垂直和水平翻转一个区域。该区域是在用户点击和恒定宽度的帮助下计算的。就在我点击图像时,整个图像变成了一种颜色,我假设每个像素都从一个像素中获取它的新颜色,为了使用我调用的内核
var width = radius;
var height = radius;
var roi = CGRectMake(center.X - width / 2,center.Y - height / 2, width, height);
return kernel.applyWithExtent(roi, roiCallback: {(n : Int32, rect: CGRect) -> CGRect in return rect; }, inputImage: image, arguments: [center, width, height])!;
我的中心和半径来自图像坐标系。 我在这里错过了什么吗?我应该将所有内容缩小到 [0,1] 吗?
最佳答案
Core Image 坐标以非标准化像素为单位。坐标是笛卡尔坐标(即原点在左下角)
关于ios - 如何正确使用 CIWarpKernel 坐标系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34454272/
我正在尝试在 ios 中构建自定义 warp 内核。 我有这个内核代码 var kernelCode = " kernel vec2 partialFlip(vec2 center,
我是一名优秀的程序员,十分优秀!