[SOLVED] ofImage not pixel perfect?

I currently have the very rigid requirement for my app that is has to draw images absolutely pixel perfect. Though this doesn’t seem to be the case with standard settings in oF.

As a test I have a FullHD picture with vertical black and white 1px lines. You can find the test pattern here: http://i.imgur.com/1m2TDa2.png

If I load that image with image.loadImage("testpattern.png") and then draw it with image.draw(0,0) the result looks like this:

You can clearly see the diagonal line going through the picture.
If you take a closer look at that “edge” you can see that the white pixels at the “bottom half”, bleed into the black pixels:

In DirectX the cause of that issue is the way the pixels are drawn to the screen (see: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx). You simply have to draw your texture at 0.5,0.5 instead of 0,0. Though in oF with OpenGL it doesn’t seem to solve the issue.
I have no clue what could cause this. I would be glad about any help with this weird issue.

I’m running Raspbian on a RaspberryPi.

I’m not seeing this on my osx machine, can you run glInfo example and post your graphics settings?

also, can you print this out:

cout << myImage.getTextureReference().texData.textureTarget << " " << GL_TEXTURE_2D << " " <<  GL_TEXTURE_RECTANGLE_ARB << endl;

where myImage is the name of your image? I’m curious if this is a texture_2d or arb texture.

I should have mentioned. I’m running raspbian on a Rasbperry Pi. GL_TEXTURE_RECTANGLE_ARB doesn’t seem to exist in that version. It throws me an error that it wasn’t declared.
The output with cout << myImage.getTextureReference().texData.textureTarget << " " << GL_TEXTURE_2D << endl; looks likes this:

3553 3553

Seems like glinfo example was also not ported to raspbian. Its not located in the examples/gl/ folder.

can you try calling ofDisableTextureEdgeHack() at the start of the code (in setup, before the image is loaded) and see if that helps?

Could be worth throwing a:

tmpImage.getTextureReference().setTextureMinMagFilter( GL_NEAREST, GL_NEAREST );

In there. If something is introducing a small inaccuracy then it’ll be a bit more obvious.

1 Like

Thank hahakid, that did the trick! Everything looking fine with that setting.

So, can you please explain to me what the meaning of Texture Edge Hacking is? I had some research on the web but couldn’t find much informations.