PGraphics alpha issue

edited November 2014 in Android Mode

Hey guys,

I was tinkering with PGraphics and noticed a little glitch when I drew stuff on the screen on Android. Can someone test this out and confirm that the right side rectangles look like they've had their alpha clipped somehow:

  PGraphics surface; 

  int amount = 1000; 

  surface = createGraphics(displayWidth, displayHeight); 

  surface.beginDraw(); 

    for (int i = 0; i < amount; i++)
    {
      float x = displayWidth * 0.5 + random(-100, 100); 
      float y = displayHeight * 0.5 + random(-100, 100);
      float scale = random(10, 200); 
      float angle = random(360);

      noStroke(); 
      fill(0, 0, 0, 2); 
      pushMatrix(); 
        translate(x - 300, y); 
        rotate(angle); 
        rect(0, 0, scale, scale);
      popMatrix(); 

      surface.noStroke(); 
      surface.fill(0, 0, 0, 2);
      surface.pushMatrix(); 
        surface.translate(x + 300, y);
        surface.rotate(angle);  
        surface.rect(0, 0, scale, scale);
      surface.popMatrix();  
    } 

  surface.endDraw(); 

  image(surface, 0, 0);

Is there something wrong in my code or is Android blending the surface with some odd colorspace (like RGB565)? OR if you see the two rectangle stacks as 1:1 it might just be my device. I tried using getSurfaceHolder().setFormat(1) which worked beautifully at showing the images but this little hiccup is left. Can anyone point me into the right direction here? Cheers! ^.^

Answers

  • After fiddling around with these, it seems that the oddities are the result of bad blending (values get rounded and do not accumulate properly) in the hardware and is not a problem in Processing.

  • @loadus i tested (2 phones) & got the same result as you; trying to add OPENGL as renderer in createGraphics() works... But only for the surface!: the other one disappears... As for pixelFormat i think that android default is not ARGB 888 but 565...But i have not tried to change that till now....

Sign In or Register to comment.