FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

16x16 icons and Graphics.drawIcon

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
Al



Joined: 10 Mar 2008
Posts: 9

PostPosted: Mon Mar 10, 2008 4:08 am    Post subject: 16x16 icons and Graphics.drawIcon Reply with quote

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 Wink )

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
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Fri Mar 14, 2008 3:03 pm    Post subject: Re: 16x16 icons and Graphics.drawIcon Reply with quote

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
View user's profile Send private message
Al



Joined: 10 Mar 2008
Posts: 9

PostPosted: Mon Mar 17, 2008 2:43 am    Post subject: Reply with quote

Hey, it works!
Great!! Cool

"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! Mr. Green
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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