2013-03-18 75 views
0

Im新增至处理。我想将.jpg或.png放在曲线和椭圆上,以便它们只能看到图像透明的位置。 我的代码如下。问题在于透明区域不完全透明,但是透明白色和不透明部分也降低了不透明度。处理:曲线上的透明图像

PImage img; 

    void setup() { 
     size(300,500); 
     frameRate(30); 
     strokeWeight(4); 
     img = loadImage("sziluettmeret.jpg"); 
    } 

    void draw() { 
     background(0, 50, 70); 
     stroke(0,70,90); 
     noFill(); 
     beginShape(); 
     curveVertex(-100, -100); 
     curveVertex(10, 10); 
     curveVertex(250, 250); 
     curveVertex(300, 300); 
     endShape(); 

     fill(255); 
     ellipse(20 ,20,15,15); 

     noFill(); 
     tint(255, 100); 
     image(img, 0, 0); 
    } 

UPDATE:

我有这个在我的代码:

loadPixels(); 
    for(int i=0; i < img.pixels.length; i++) { 
    tmpColor = img.pixels[i]; 
    tmpRed = red(tmpColor); 
    tmpGreen = blue(tmpColor); 
    tmpBlue = green(tmpColor); 
    tmpAlpha = 255 - ((tmpRed + tmpGreen + tmpBlue)/3); 
    img.pixels[i] = color(2*tmpRed,tmpGreen/2,tmpBlue,0); 
    if(0xFFFFFF == tmpColor) 


     } 
    updatePixels(); 

图片不变得透明。 (但它变成紫色,所以循环肯定会在每个像素上运行)

+0

“,以便他们只能看到图像透明的位置。”谁可以看到什么?你只想在抽奖中看到图像吗?也许是面具?请让自己更清楚。 – 2013-03-19 07:42:58

回答

1

tint()不会执行greenscreening。它会重新着色你的图像(如果你使用非中性色),并设置混合透明度,所以通过色调(255,100),你的图像不透明度约为0.39。做绿屏(或在你的情况下,白屏),当你加载图像时,你想穿过图像的像素,然后设置不透明度为0,无论何时r/g/b是255,有效地“移除”你所有的白色像素。

+0

但我该如何读取像素的颜色?特别是,我如何阅读rgb信息? – user1008673 2013-03-19 06:19:04

+0

这是http://processing.org/reference是什么,它列出了你需要的所有功能=) – 2013-03-19 13:17:20

+0

我认为我编辑了这条评论后,我发现这... – user1008673 2013-03-19 21:46:55