We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Rotated PImage and PNG Transparency Pixel Smoothin
Page Index Toggle Pages: 1
Rotated PImage and PNG Transparency Pixel Smoothin (Read 2152 times)
Rotated PImage and PNG Transparency Pixel Smoothin
Jan 12th, 2010, 5:03pm
 
Hello,

I have been writing a program in Processing that displays PNG's on a solid background color as PImages.  I found that when I use rotate, and some times translate, when drawing these PImages the transparent pixels will blend with the nontransparent pixels, mixing their colors.  This results in some visible discoloration of the pixels which makes for some odd looking edges of my PImages.

I have done some experimentation and found that rotating solid white images can have similar results, where borders become visible on a solid same colored background.  Is this possibly related to the transparency blending, I don't know.  Perhaps I should use another method to display the images rather than using PImage.

This may be related to this thread/topic: processing.org/discourse/yabb2/num_1202337325.html

Here is some code that demonstrates the effect I am trying to describe, at least with the borders becoming visible:
Code:
import processing.opengl.*;
PImage exampleImage;
PImage test = new PImage();
void setup(){
 size(200, 200, OPENGL);
 hint(DISABLE_OPENGL_2X_SMOOTH);//enabled or disabled doesn't seem to have much effect either way
 noSmooth();
 exampleImage = createImage(width/8,height/8,ARGB);
 int pixelCount = (width/8*height/8);
}
void draw(){
 background(255,255,255);
 for(int i = 0; i<width/8*height/8; i++){
   exampleImage.pixels[i]= color(255,255,255,255);
 }
 pushMatrix();
 translate(mouseX,mouseY);//some times colored boreders appear with translation.
 rotate(mouseX/2); //colored borders appear with rotation.
 image(exampleImage,0,0);
 popMatrix();
}
 

Look carefully for the borders of a rectangle near the mouse when hovering/moving your moue over the canvas.  When I do so I see about half of a dark outline of the white PImage over the white background.

My specs are: 32-Bit Windows XP, 2GB RAM, 256MB NVidia 7600GT, AMD X2 6000.

Any help in fixing this blending colors between transparent and non-transparent pixels and showing of borders would be much appreciated.   Thank you.
Re: Rotated PImage and PNG Transparency Pixel Smoothin
Reply #1 - Jan 12th, 2010, 5:17pm
 
You might want to look at the OpenGL blending options... perhaps the default is not what you need.  The site is offline but Ira Greenberg posted a nice blending test (allows you to cycle through them) that can still be retrived from google cache for the moment.  Maybe someone can put it in the Hacks section before it disappears.
http://74.125.93.132/search?q=cache:0QPN0etLW4MJ:boxofbooze.com/processing/glblend.html+blending+space+junk&cd=1&hl=en&ct=clnk&gl=us
Re: Rotated PImage and PNG Transparency Pixel Smoothin
Reply #2 - Jan 12th, 2010, 7:57pm
 
Thanks for the link jeffg.  Interesting effects there.  Perhaps OpenGL subtracts the colors when blending (or bi-linear filtering, or anti-anti aliasing)?  I really don't know.  Ill look through that link and experiment some more.

However I am still unsure of how to do away with the black borders appearing on the PImages after rotating while using OpenGL.  Please note that when using P3D to rotate the PImages there no such visible borders/lining.

Thanks.
Page Index Toggle Pages: 1