Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Drawing PNG images gets ugly

Drawing PNG images gets ugly

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Worstje   Netherlands  (899 posts)  Bio
Date Thu 13 Nov 2008 10:33 AM (UTC)
Message
It seems drawing PNG images with support for alpha-transparency isn't supported. This is kind of annoying, since my miniwindows have variable borders (dependant on the area), and the images I have produce strange results no matter what way I try to draw them. (Or they look plain weird. ^^) Probably because of alpha-transparency being used to block colours out and such.

I could manually convert them to BMP, but then I lose the funky alpha-transparency when drawing them, which is kind of nice. Since you are already using libpng, I imagine you convert them to BMP in memory, causing the funky result. On top of that, there is no real way to use PNG images to their full advantage.

What the best way is to implement 'real' PNG support with MUSHclients current API I am not sure. You could add an 'asSource' parameter to WindowLoadImage that would prevent conversion to BMP, and only perform the conversion to BMP once it is needed (blendimage and such come to mind). Or you could try to handle it fully transparentially. I reckon libpng has some really simply drawing routines though, if only the basic draw and stretchclipped draws, so the 'transparentially' thing can be accomplished I think.

Alternatively, which would be simpler, you could make a separate LoadPNG and DrawPNG functions, although that could get a bit ugly.

(P.S.: Nick, I know I still promised in another thread to.. do something which escapes me right now. Life's been busy, although I do know I promised. ^^)
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #1 on Thu 13 Nov 2008 04:28 PM (UTC)
Message
The issue is probably more likely that either a) you are using it on something like 98, which doesn't support the method of transparency being used, or b) he just hasn't implemented it. The later could be likely, given that libpng is hard to implement "correctly", such that many applications do not correctly support gamma, if at all, and more than a few refuse to touch transparency either, due to the complications of how the thing works. Fault MS for not supporting it **correctly** natively themselves, or the libpng makers for failing to make a "clear" documentation on how to make sure it "does" work as intended. lol
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Thu 13 Nov 2008 05:18 PM (UTC)
Message
My understanding is that rendering alpha channel onto a window with another moving window beneath it isn't easy, because you need to constantly redraw the covering window when things change. Of course, it's possible, it's just not necessarily easy at all if your windowing system isn't set up for it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #3 on Thu 13 Nov 2008 08:46 PM (UTC)

Amended on Thu 13 Nov 2008 08:47 PM (UTC) by Worstje

Message
Actually, in this case, I was keeping it to the simplest case possible. My miniwindow itself was NOT transparent. I had an alpha-transparent PNG loaded, and used WindowDrawImage to draw the image on a background image I already drew a few steps prior. I tried both the normal and transparent modes, but neither gave the effect of what would happen when I'd paste one of those PNGs on a similar background in a program like Paint.Net or Photoshop.

And I'm using plain good old XP. Should be good enough, I reckon.

Edit: I don't care about gamma at all. I'm just looking for soft edges, rather than 1/0 transparency which causes my images to look... very different.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Thu 13 Nov 2008 09:01 PM (UTC)
Message
Ah, I didn't realize that you wanted the alpha to only be w.r.t. what's already on the miniwindow canvas, not what's below it. This should just be a simple question of using an alpha-aware drawing routine, I think.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,098 posts)  Bio   Forum Administrator
Date Reply #5 on Sat 15 Nov 2008 03:46 AM (UTC)
Message
At present I don't process the alpha information from the PNG files because there was no way, that I was aware of, that would let me easily drawn (ala BitBlt) with an alpha channel.

I was perhaps wrong, TransparentBlt may do it for me, however the documentation says "[This is preliminary documentation and subject to change.] ". Since I have an old copy of the compiler, it may well work now, so I'll try looking into it for the next version.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,098 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 06 Jul 2009 04:49 AM (UTC)
Message
Version 4.42 of MUSHclient implements WindowDrawImageAlpha which draws PNG images respecting the alpha channel (if it has one), thus allowing you to draw images with soft edges.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,006 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.