Gimp python-fu 我如何 select 一个多边形?
Gimp python-fu how do I select a polygon?
问题
我需要在图像上进行数百次多边形选择。为了提供帮助,我一直在尝试使用 python 控制台创建一个脚本,该脚本将以计算的方式执行此操作(相同大小的区域,数百个不同的起点)。我在 Windows 10 机器上使用 GIMP 2.8.18。
问题是函数 pdb.gimp_image_select_polygon 似乎不起作用。
代码
这是我在 python 控制台中尝试做的事情的基本框架:
theImage = gimp.image_list()[0]
OP_ADD = 0
POINT_COUNT = 5
x = 0
y = 0
points = [0.0 for i in range(0,10)]
points[0] = 64.0 + (128.0 * x)
points[1] = 64.0 * y
points[2] = 128.0 * x
points[3] = 32.0 + (64.0 * y)
points[4] = 64.0 + (128.0 * x)
points[5] = 64.0 + (64.0 * y)
points[6] = 128.0 + (128.0 * x)
points[7] = 32.0 + (64.0 * y)
points[8] = 64.0 + (128.0 * x)
points[9] = 64.0 * y
pdb.gimp_image_select_polygon(theImage, OP_ADD, POINT_COUNT, points)
运行时,什么都没有发生。 OTOH,如果我使用另一个选择功能,我会得到一个选择:
pdb.gimp_image_select_rectangle(theImage, 0, 64 ,0 ,128 ,32)
我在使用 gimp_image_select_polygon 时没有发现回溯错误,所以我知道我有正确的参数数量和正确的参数类型。我尝试了各种方法,但无法在网上找到太多帮助。
有没有人发现我的代码有问题,或者 GIMP 中的 python 引擎完全没有问题?
长度参数是坐标的数量,而不是点的数量(因此,通常是双精度)
OP_REPLACE
在我的版本中没有定义。
对于 (100,100) 处的 100x100 正方形:
p=[100,100,100,200,200,200,200,100]
pdb.gimp_image_select_polygon(image, CHANNEL_OP_REPLACE,len(p),p)
问题
我需要在图像上进行数百次多边形选择。为了提供帮助,我一直在尝试使用 python 控制台创建一个脚本,该脚本将以计算的方式执行此操作(相同大小的区域,数百个不同的起点)。我在 Windows 10 机器上使用 GIMP 2.8.18。
问题是函数 pdb.gimp_image_select_polygon 似乎不起作用。
代码
这是我在 python 控制台中尝试做的事情的基本框架:
theImage = gimp.image_list()[0]
OP_ADD = 0
POINT_COUNT = 5
x = 0
y = 0
points = [0.0 for i in range(0,10)]
points[0] = 64.0 + (128.0 * x)
points[1] = 64.0 * y
points[2] = 128.0 * x
points[3] = 32.0 + (64.0 * y)
points[4] = 64.0 + (128.0 * x)
points[5] = 64.0 + (64.0 * y)
points[6] = 128.0 + (128.0 * x)
points[7] = 32.0 + (64.0 * y)
points[8] = 64.0 + (128.0 * x)
points[9] = 64.0 * y
pdb.gimp_image_select_polygon(theImage, OP_ADD, POINT_COUNT, points)
运行时,什么都没有发生。 OTOH,如果我使用另一个选择功能,我会得到一个选择:
pdb.gimp_image_select_rectangle(theImage, 0, 64 ,0 ,128 ,32)
我在使用 gimp_image_select_polygon 时没有发现回溯错误,所以我知道我有正确的参数数量和正确的参数类型。我尝试了各种方法,但无法在网上找到太多帮助。
有没有人发现我的代码有问题,或者 GIMP 中的 python 引擎完全没有问题?
长度参数是坐标的数量,而不是点的数量(因此,通常是双精度)
OP_REPLACE
在我的版本中没有定义。
对于 (100,100) 处的 100x100 正方形:
p=[100,100,100,200,200,200,200,100]
pdb.gimp_image_select_polygon(image, CHANNEL_OP_REPLACE,len(p),p)