Hi,
I want to display some textures on opengl with transparency. I have some png files load on a xrc resource file. The problem is when I get this png files I use the method "LadBitmap" and after that I use "ConvertToImage" to finally get my wxImage variable. My problem is that I don't get any Alpha Channel after the process and I need this Alpha channel to create the opengl texture.
I know is possible to create wxImage using the follow contructor:
wxImage(wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1)
but how can I put a png file on a xrc resource to read it as wxInputStream???
Or maybe is any another way to do what I need...
thanks in advance..
[SOLVED]how to get wximage with alpha channel from resources Topic is solved
[SOLVED]how to get wximage with alpha channel from resources
Last edited by idhan on Thu Apr 05, 2007 4:26 pm, edited 1 time in total.
It should be no problem to load png with alpha channel. I've done simular thing before without any problem.
If you want load a file to input stream. Here is the code:
If you want load a file to input stream. Here is the code:
Code: Select all
wxFFileInputStream in(_T("example.png"));
if ( in.IsOK )
{
// do whatever you want
}
Here is the solution.
After you get you GetBitmap() from you xrc resource and convert it to wxImage with ConvertToImage(). You will get you image that keep you transparency as Mask, so... after that you apply to you image SetMask(true) and if you image doesn't get alpha channel (HasAlpha()) then you apply InitAlpha().
best regards
After you get you GetBitmap() from you xrc resource and convert it to wxImage with ConvertToImage(). You will get you image that keep you transparency as Mask, so... after that you apply to you image SetMask(true) and if you image doesn't get alpha channel (HasAlpha()) then you apply InitAlpha().
best regards