JTalton's picture

Issue: GameWindow Icon Support

Project:The Open Toolkit library
Version:1.0-beta-1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I am getting to the point in my project where it would be nice to post screen shots. It would be nice to have Icon support for the GameWindow.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JTalton's picture

#31

The icon support works great. I did notice one quirk. If I use a multi resolution icon, it will pick a high resolution version and try to use it. This results in it scaling down the high resolution to 16x16, which looks grainy and the transparency does not look good. I ended up making a second icon just for the 16x16. I'm not sure what are the considerations for highe dpi settings or other operating systems than windows.

the Fiddler's picture

#32

Thanks.

This issue can be fixed easily on Windows by sending a second WM_SETICON message with wparam = ICON_SMALL.

X11 supports multi-res icons too, but we need the actual icon data for that. Do you know if there is any way to extract the different resolutions from a multi-res icon? (ToBitmap() returns only the first resolution).

the Fiddler's picture

#33

The small icon should now be set correctly on win32 when using multi-icon files. I don't have access to the platform right now, JTalton can you please test that the issue is fixed?

JTalton's picture

#34

"Do you know if there is any way to extract the different resolutions from a multi-res icon? (ToBitmap() returns only the first resolution)"

MemoryStream memoryStream = new MemoryStream();
icon.Save(memoryStream);
IconBitmapDecoder iconBitmapDecoder = new IconBitmapDecoder(memoryStream, BitmapCreateOptions.None, BitmapCacheOption.Default);
 
foreach (BitmapFrame decoderBitmapFrame in iconBitmapDecoder.Frames)
    // TODO something here...
 
memoryStream.Close();

"The small icon should now be set correctly on win32 when using multi-icon files"
I'll test this soon and post the results.

kanato's picture

#35

IconBitmapDecoder is part of WPF, and I think not supported under mono. The only way to do it as far as I can tell is to save the icon to memory like that and then parse the ico file format. There is some example source code for doing that here:
http://www.codeproject.com/KB/vb/MultiIcon.aspx

the Fiddler's picture

#36

Thanks for the hints.

SVN trunk actually contains a fully featured Icon parser picked straight out of Mono (disabled by default, #define EXPERIMENTAL to enable). I haven't decided what's the best way to proceed with this issue, yet: on one hand this code would allow OpenTK consumers to work without referencing System.Drawing at all (right now you cannot really use GameWindow without System.Drawing), but on the other hand that's a lot of code to maintain...

JTalton's picture

#37

"The small icon should now be set correctly on win32 when using multi-icon files"
Tested - seems to work good on Windows.

the Fiddler's picture

#38

Status:in progress (review)» fixed

Thanks, marking this as fixed.

If you encounter any icon-related bugs, please open new bug reports!

the Fiddler's picture

#39

Version:0.9.x-dev» 1.0-beta-1
Status:fixed» closed

Closing issues fixed in 1.0 beta-1.