如何在Rebol中替换位图中某些颜色的所有像素?

时间:2010-05-24 13:16:09

标签: rebol

假设我有一张照片,我想通过改变颜色来创建一些变化。怎么做?

我不想对图片应用滤色器,我想通过测试颜色像素来逐像素地改变像素颜色,如果它是红色,我想把它变成蓝色。

2 个答案:

答案 0 :(得分:1)

在Rebol中,图像也是系列,因此您可以使用大多数系列函数来更改/查找rgb颜色等。

i: load %test.png
type? i
image!
first i
255.255.255.0 (the last value is alpha)
change i 255.0.0.0 ;change the first rgba value to red
view layout [image i] ;you can see the upper-left pixel is now red

您可以将所有rgba值转储到图像中:

forall i [print first i]

你也可以改变继续部分:

change/dup head i blue 100 ;change first 100 pixels to blue

你也可以使用i / rgb和i / alpha,这些是二进制值(字节) 并且您可以使用复制来获取图像的一部分:

j: copy/part at i 100x100 50x50 ;copy from 100x100 to 150x150 to a new image.

答案 1 :(得分:0)

使用此处记录的一些图像处理功能:    http://www.rebol.com/docs/view-guide.html

演示程序显示其中的一些实际操作:     http://www.rebol.com/view/demos/gel.r