View previous topic :: View next topic |
Author |
Message |
Al
Joined: 10 Mar 2008 Posts: 9
|
Posted: Mon Mar 10, 2008 4:08 am Post subject: 16x16 icons and Graphics.drawIcon |
|
|
Hello, everybody!
First of all - nice library, Chris!
Tried DWT before it and find myself liking DFL better (maybe because I'm a Windows guy basically and find Java-ish GUIs.. weird a bit )
Having said this - I was hoping, someone knows how to circumvent the following problem:
Graphics.drawIcon doesn't draw small (e.g. 16x16) icons correctly. What I mean is: I load my 16x16 icon from resources (Application.resources.getIcon), then draw it in my paint event handler like so:
Code: | gfx.drawIcon(_icoNewBtn, 1, 1); |
This draws my icon stretched to 32x32 size (or, if the icon contains a 32x32 version, it draws that)
Now, from what I have read on many win-programming forums, DrawIconEx (which drawIcon uses) needs to know how big is the icon.
Fine, I do this -
Code: | gfx.drawIcon(_icoNewBtn, Rect(1, 1, 16, 16)); |
Well, it works. Kinda. I see a 16x16 icon, drawn as a 16x16 icon, BUT it looks lousy. Like this:
On the left you can see the same icon in my file manager, on the right - drawn with drawIcon.
If you ask me, it looks like the icon has been upscaled and then downscaled.
I have tried this approach (LoadImage / DrawIconEx) in Visual C++ 2003, the result is the same (and looks worse, with a different, more complex icon). It must be a Windows bug then, but maybe someone here knows how to draw a small icon nicely despite all this? |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Fri Mar 14, 2008 3:03 pm Post subject: Re: 16x16 icons and Graphics.drawIcon |
|
|
Perhaps you're using the getIcon with defaultSize=true, so it would load stretched as 32x32 and drawn shrunk back down to 16x16, causing some distortion. |
|
Back to top |
|
|
Al
Joined: 10 Mar 2008 Posts: 9
|
Posted: Mon Mar 17, 2008 2:43 am Post subject: |
|
|
Hey, it works!
Great!!
"Before and after" shot (upscaled 4x to make changes obvious):
On the left - stretched and compressed version, on the right - as it was intended to look.
Thanks a lot! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|