Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
On Sat, 2009-05-02 at 20:38 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
Is that right? I simply assumed it would screw it up. If the problem can be solved with fixes to user32 or gdi32, then I can probably find the solution. If it involves work on winex11, then I'm not really the right guy for the job.
On Sat, May 2, 2009 at 8:57 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 20:38 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
Is that right? I simply assumed it would screw it up. If the problem can be solved with fixes to user32 or gdi32, then I can probably find the solution. If it involves work on winex11, then I'm not really the right guy for the job.
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
On Sat, 2009-05-02 at 22:56 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 8:57 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 20:38 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
Is that right? I simply assumed it would screw it up. If the problem can be solved with fixes to user32 or gdi32, then I can probably find the solution. If it involves work on winex11, then I'm not really the right guy for the job.
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
The reason is that the outlines will look aliased, and there will be no drop-shadows - without alpha the Tango icons won't look better than the current set. Also, I figured that icon rendering should be fixed for the sake of wine as a whole - which I think it should. It seems like a good little task for a wine beginner, and indeed I've made a lot of progress - I'm just a bit stuck.
The culprit is a transfer through StretchDIBits in user32 which strips the alpha channel. I can't see a way round it - using StretchBlt doesn't help, and neither does GdiTransparentBlt.
Another insentive: I suspect fixing this would also fix bug #201 which is now over 8 years old!
2009/5/3 Joel Holdsworth joel@airwebreathe.org.uk:
On Sat, 2009-05-02 at 22:56 +0200, Roderick Colenbrander wrote:
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
The reason is that the outlines will look aliased, and there will be no drop-shadows - without alpha the Tango icons won't look better than the current set. Also, I figured that icon rendering should be fixed for the sake of wine as a whole - which I think it should. It seems like a good little task for a wine beginner, and indeed I've made a lot of progress
- I'm just a bit stuck.
The culprit is a transfer through StretchDIBits in user32 which strips the alpha channel. I can't see a way round it - using StretchBlt doesn't help, and neither does GdiTransparentBlt.
Another insentive: I suspect fixing this would also fix bug #201 which is now over 8 years old!
What format are your Tango icons in? Are you converting them to .ICO files as you go, or leaving them in PNG/some other known alpha channel supporting format?
On Sun, May 3, 2009 at 2:44 AM, Ben Klein shacklein@gmail.com wrote:
2009/5/3 Joel Holdsworth joel@airwebreathe.org.uk:
On Sat, 2009-05-02 at 22:56 +0200, Roderick Colenbrander wrote:
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
The reason is that the outlines will look aliased, and there will be no drop-shadows - without alpha the Tango icons won't look better than the current set. Also, I figured that icon rendering should be fixed for the sake of wine as a whole - which I think it should. It seems like a good little task for a wine beginner, and indeed I've made a lot of progress
- I'm just a bit stuck.
The culprit is a transfer through StretchDIBits in user32 which strips the alpha channel. I can't see a way round it - using StretchBlt doesn't help, and neither does GdiTransparentBlt.
Another insentive: I suspect fixing this would also fix bug #201 which is now over 8 years old!
What format are your Tango icons in? Are you converting them to .ICO files as you go, or leaving them in PNG/some other known alpha channel supporting format?
We do support some alpha support using XRender, can't you use this too? I think that's the general method for using alpha at the moment on X.
Roderick
On Sun, 2009-05-03 at 16:05 +0200, Roderick Colenbrander wrote:
We do support some alpha support using XRender, can't you use this too? I think that's the general method for using alpha at the moment on X.
Yes and I'm using GdiAlphaBlend - for rendering, and I have fixes to use it. It's what you need to enable DrawIcon and DrawIconEx to draw properly.
The reason is to do with the way *loading* works. Icons get loaded in arbitrary sizes and colour depths, but of course only compatible HBITMAPs can be displayed e.g. a 4-bit icon has to be upsampled to 32-bit before it can be displayed on my system. As a solution to both these problems CURSORICON_CreateIconFromBMI has an internal call to StretchDIBits, which applies both depth and size conversions. The problem is that this call seems to loose the alpha channel in doing so.
I guess I should write a test to find out what StretchDIBits *should* do - whether we can use it, even theoretically.
Once we get to the stage of returning a full formed HICON to the app, it's plain sailing. My DrawIcon patch can render alpha channel icons no problem, and hopefully a DrawIconEx patch will soon follow. The problem is that the only way to create one in wine right now is with CreateIcon!
Joel
On Sat, May 2, 2009 at 11:18 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 22:56 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 8:57 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 20:38 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
Is that right? I simply assumed it would screw it up. If the problem can be solved with fixes to user32 or gdi32, then I can probably find the solution. If it involves work on winex11, then I'm not really the right guy for the job.
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
The reason is that the outlines will look aliased, and there will be no drop-shadows - without alpha the Tango icons won't look better than the current set. Also, I figured that icon rendering should be fixed for the sake of wine as a whole - which I think it should. It seems like a good little task for a wine beginner, and indeed I've made a lot of progress
- I'm just a bit stuck.
The culprit is a transfer through StretchDIBits in user32 which strips the alpha channel. I can't see a way round it - using StretchBlt doesn't help, and neither does GdiTransparentBlt.
Another insentive: I suspect fixing this would also fix bug #201 which is now over 8 years old!
I just looked a little more into it. As you mentioned StretchDIBits in user32 removes the alpha channel. According to this post at MSDN (http://msdn.microsoft.com/en-us/library/dd145023(VS.85).aspx) the function got extended in Vista to include PNG support because PNG is used for most icons in Vista. It might be useful to check that out. The page mentions it was meant for printers but most likely they also use this for icon rendering. I think it can be used in cooperation with XRender (there are various xrender examples for dealing with alpha).
Roderick
On Sun, May 3, 2009 at 6:28 PM, Roderick Colenbrander thunderbird2k@gmail.com wrote:
On Sat, May 2, 2009 at 11:18 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 22:56 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 8:57 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
On Sat, 2009-05-02 at 20:38 +0200, Roderick Colenbrander wrote:
On Sat, May 2, 2009 at 6:55 PM, Joel Holdsworth joel@airwebreathe.org.uk wrote:
Hi All,
I've hit a bit of a wall with alpha blended icons. CreateIcon is working fine for icon creation, but ExtractIcon and LoadIconFromResource etc. are all proving more of a problem. All of these use various GDI DIB functions to coerce the icon bitmap to the correct colour depth and size. The problem is that preserving the alpha channel through these DIB functions seems to be impossible because they go via X11, so until the dib engine is merged (after hell freezes over) I'm not sure I can go much further.
Joel
If you say X11 might be problematic note that more and more display drivers are offering visuals with alpha, so 32-bit ones instead of 24-bit. You could force the selection of such a visual in winex11.drv for testing.
Roderick
Is that right? I simply assumed it would screw it up. If the problem can be solved with fixes to user32 or gdi32, then I can probably find the solution. If it involves work on winex11, then I'm not really the right guy for the job.
Why again did you need this specific alphablend method? The icon can't be converted to use some basic color keying for transparency or so?
The reason is that the outlines will look aliased, and there will be no drop-shadows - without alpha the Tango icons won't look better than the current set. Also, I figured that icon rendering should be fixed for the sake of wine as a whole - which I think it should. It seems like a good little task for a wine beginner, and indeed I've made a lot of progress
- I'm just a bit stuck.
The culprit is a transfer through StretchDIBits in user32 which strips the alpha channel. I can't see a way round it - using StretchBlt doesn't help, and neither does GdiTransparentBlt.
Another insentive: I suspect fixing this would also fix bug #201 which is now over 8 years old!
I just looked a little more into it. As you mentioned StretchDIBits in user32 removes the alpha channel. According to this post at MSDN (http://msdn.microsoft.com/en-us/library/dd145023(VS.85).aspx) the function got extended in Vista to include PNG support because PNG is used for most icons in Vista. It might be useful to check that out. The page mentions it was meant for printers but most likely they also use this for icon rendering. I think it can be used in cooperation with XRender (there are various xrender examples for dealing with alpha).
Roderick
Have you also tried to use the GDI AlphaBlend function? This is the one which should be used I think and we back it by XRender ..
Roderick
Roderick Colenbrander ha scritto:
Have you also tried to use the GDI AlphaBlend function? This is the one which should be used I think and we back it by XRender ..
Roderick
Sorry for the OT : apropos AlphaBlend and RGBA bitmaps... what happens with BitBlt on a destination DIB which has alpha channel ? it gets overwritten or the dest alpha channel is simply ignored ? I mean BitBlt(dstBmp......., SRC_COPY) what happens to dstBmp alpha ? and BitBlt(dstBmp......., SRC_AND) ???
Max