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 › Black thin border around rotated images
Page Index Toggle Pages: 1
Black thin border around rotated images (Read 1675 times)
Black thin border around rotated images
Feb 6th, 2008, 11:35pm
 
I use OpenGl because it has a better blend (multiply) method than the standard processing blend.

But i noticed black borders as soon as i rotate an image.
In this example i have the same image shown twice and multiplied on each other. Notic the black jagged edge.

Has anyona an idea in which direction too look ?, couldn't find a solution in the forum or the web.

Thanks in advance.

Code:

import processing.opengl.*;
import javax.media.opengl.*;

PGraphicsOpenGL pgl;
GL gl;

float rY;
float rZ;
float rX;

PImage a;
PImage b;

void setup() {
size(500, 500, OPENGL);
hint(ENABLE_OPENGL_4X_SMOOTH);
background(255);

b = loadImage("http://www.muhneer.nl/files/preview/COLIN_SMALL.gif");
a = loadImage("http://www.muhneer.nl/files/preview/fff_pic.jpg");

pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;

// Begin opengl blending
pgl.beginGL();
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_ZERO); // Activate the multiply effect
pgl.endGL();

translate(240, 240);
image(b, 0, 0);
rotateZ(radians(20));
image(b, 0, 0);

}
Re: Black thin border around rotated images
Reply #1 - Feb 7th, 2008, 3:26pm
 
I found out that it has to do with the blend method im using : gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_ZERO);  to multiply the images but this generates the black border because once rotated not all the pixels could be multiplied right.

Trying to fix it one way or another.
Re: Black thin border around rotated images
Reply #2 - Feb 20th, 2008, 12:19pm
 
Finally fixed with a way around.

Robert (flight404) pointed me in order to overcome this problem to use the image as a texture on a quad.

You are than able to remove the black edge by cropping the texture, but this wasn't even necessary. By using the picture as a texture the black line dissapeared.

Thanks.

Code:

// Texture
tex.bind();
tex.enable();

// Image
gl.glBegin(GL.GL_QUADS);
gl.glNormal3f( 0.0f, 0.0f, 1.0f);
gl.glTexCoord2f(0, 0); gl.glVertex2f(0, ((designObjects[objectId].objectHeight/100)*objectScale));
gl.glTexCoord2f(1, 0); gl.glVertex2f(((designObjects[objectId].objectWidth/100)*objectScale), ((designObjects[objectId].objectHeight/100)*objectScale));
gl.glTexCoord2f(1, 1); gl.glVertex2f(((designObjects[objectId].objectWidth/100)*objectScale), 0);
gl.glTexCoord2f(0, 1); gl.glVertex2f(0, 0);
gl.glEnd();

tex.disable();
pgl.endGL();
Re: Black thin border around rotated images
Reply #3 - Apr 26th, 2008, 4:30pm
 
hello

could you post some less context dependant code ?

I try to replace :

beginShape();
texture(monAvatar2);
textureMode(NORMALIZED);
pushMatrix();
rotateX(a);
rotateY(a*2);
vertex(x, y, 0, 0);
vertex(x2, y, 64, 0);
vertex(x2, y2, 64, 64);
vertex(x, y2, 0, 64);
popMatrix();
endShape();

with a GL_QUADS equivalent, so that I could get rid of these annoying thin black borders

could you help me please ?
Page Index Toggle Pages: 1