You can try to use this C++ command-line tool. There is a precompiled windows binary and an example of a modified image. It does not do anything with the image, it just sets zero alpha border around it (no premultiplication). To build this you need libjpeg and libpng (you can get x86 / x64 prebuilt windws libs here).
A couple of notes about OpenGL. The bleeding of the edges can be only up to 1 pixel wide and is caused by repetitive texture application. You can remove it even if using GL_LINEAR
or GL_LINEAR_MIPMAP_LINEAR
mode by setting clamp mode to GL_CLAMP_TO_EDGE
:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
In case you are not using GL_TEXTURE_2D
, you need to replace that with whatever you are using. The bleeding is kind of suspicious, and may be also related to the RGB color that is in the regions that have zero alpha. The correct way to set up the blending mode is:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
This way anything that is with zero alpha does not have any influence on the pixels under it. However, the interpolation may cause bleeding of the black pixels with zero alpha to the first pixel of the image with 100% alpha, yielding a thin black border. To get rid of that, it is necessary to replicate the color of the edge of the original image to the border and set zero alpha.
To do that, define __BLEED_EDGE
when compiling, or use the precompiled AddTransparentBorder_BleedEdge
version. There is also an example of an image with the edges duplicated. You can try to use those examples first and see if the black edge occurs.