About alpha blend.

Started by toyoPon3, April 27, 2011, 03:32:05

Previous topic - Next topic

toyoPon3

I am studying the alpha blending by using the LWJGL.
My test program blends the image01(Dst) and image02(Src).
And I try some patterns (the combo of the image file format).

But there are the good case (image03), and the bad case (image04).
I want to clear up this, I post this question.

--------
Case1
Dst image:bmp file
Src image:bmp file
<result>
 Test program moved as planned.

Case2
Dst image:bmp file
Src image:png file without alpha parameter.
<result>
 Test program moved as planned.

Case3
Dst image:bmp file
Src image:png file with alpha parameter (aPNG file).
<result>
 Test program did not move as planned.
 The result image was the blending image surely, but it lost the color of the src image.
<detail>
The png image file shown above was converted from the bmp file by free tool.
My program loads the texture as shown below, and tells whether the image has the alpha parameter or not.
[Source01]
  textureSrc = TextureLoader.getTexture("PNG", new FileInputStream("res/font_withAlpha.png"));
  System.out.println(" Image Alpha   : "+texture.hasAlpha());

I confirmed that the image has the alpha value by reading the console text shown below.
 " Image Alpha   : true" [Console01]


My Question
Why the result image lost the color in Case3?

I think four points.

1.Might I miss-set the first parameter? (the source is shown in Source01.)
 Are the parameter good?

2.Might the aPNG be file bad-converted?
 But, texture.hasAlpha() returns "true".
 And I confirmed that the aPNG file had the color by using the viewer "IrfanView".
 I want to use the another valid aPNG file.
 Do you know the download site that supplies the sample aPNG file?
 If you know, please tell me.

3.Might my program have the bags in another line?
 I don't want to distrust this because case1 and case2 moved as planed.
 
4.Might the function "getTexture" not correspond to the aPNG?
 I don't want to distrust this......



CodeBunny

You're using GL11.glBlendFunc(), right?

toyoPon3

To CodeBunny.
Nice to meet you and thank you for posting my question.
>>You're using GL11.glBlendFunc(), right?
Yes.
I use the function "GL11.glBlendFunc".
The setting parameter is shown below.
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

This setting is common in Case1, Case2, and Case3.

jediTofu

Personally, IrfanView created bad alpha PNGs for me.  When I created an alpha for the exact same PNG using GIMP it worked.  It could be Slick-Util's fault instead since the PNG looks fine in viewers, just doesn't work in LWJGL.

Try using GIMP or another program to add an alpha.  If that doesn't work, then it's a problem with your code.
cool story, bro

toyoPon3

To jediTofu

Hello.
I used the tool "GIMP" on your advice.
Then, my program moved as planned!

So, I found that the problem was in the tool.

The tool which I used was not "IrfanView " but "PNGeditr".
I used the "IrfanView" for only viewing.

Thank you for your advice.