Results 1 to 17 of 17

Thread: [RESOLVED] Blurry Menu Images

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Resolved [RESOLVED] Blurry Menu Images

    Im using xmal code to create amy menu items with images, no issues other then the images are coming out all blurry (no I dont need glasses lol).
    Ive tried using several types (png, bmp, ico) from the ones provided from VS but all still the same. Used 16x16 in the screen shot but if I use 32x32 the png ones are clear, just too damn large lol.

    Oh and why doesnt WPF menu Icon property support icons?

    Is there some property setting I need to set or ???

    Thanks
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Blurry Menu Images

    My understanding is that this is because 16x16 in WPF is not 16 pixels by 16 pixels. WPF does not measure in pixels (to enable it to be more monitor independent). So if you have a really low resolution monitor that makes everything on screen huge then the icons are going to be the same percentage of that screen that they were on a different monitor with a higher resolution - therefore if they were small images originally then they will be blurred on the first monitor, where as on the second monitor with the higher resolution they will be clearer because they will be more like their original size.

    The solution? Use vector based images (remember all the controls in WPF are vector based so that they stay clear and sharp no matter the size). One way of doing this is to use a program like Adobe Illustrator to create your image and then use the XAML plug in to export the image as XAML paths. You can also use Expression Design to do this. Obviously thats a massive pain in the ass to do that for all of your images though and most of the time its not even possible because you might not have made the image yourself so dont have access to the original Adobe Illustrator or Expression Design files (you cant just open an existing image in these programs and export it as XAML).
    So basically I just try to find the right sized icon for a common resolution such as 1024x768 and then I test this on a few other resolutions to make sure it still looks fairly good. Ironic really that in making WPF more monitor/resolution independent they seem to have made some things worse for different resolutions/DPIs...

    if I use 32x32 the png ones are clear, just too damn large lol.
    I find using larger images and then scaling them down by just setting the Width and Height properties of the Image in XAML works well sometimes

    EDIT: Just found a few workarounds that you might want to look at, havent tried any yet but the first one looks promising (the second link is talking about the same thing that ends up being done in the first link)
    http://stackoverflow.com/questions/5...pixels-working
    http://blogs.windowsclient.net/maker...lverlight.aspx
    http://blogs.msdn.com/dwayneneed/arc...y-bitmaps.aspx
    Also looks like my theory on why this happens was rubbish

    PS, I'm surprised you havent complained about the blurry text as well yet Thats supposedly getting fixed in .NET 4.0 (as of the next BETA)
    Last edited by chris128; Sep 3rd, 2009 at 03:25 PM.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Blurry Menu Images

    Woah I wish I had looked into this sooner... setting the RenderingOptions.BitmapScalingMode to NearestNeighbour has made all of my images look so much better! However, it does make them move a tiny tiny bit to the left of where they originally were (or at least it has on the 4 I just tried it on)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Blurry Menu Images

    Hmm, I dont have that render option as shown. Only HighQuality, not NearestNeighbor.

    RenderOptions.BitmapScalingMode="HighQuality"

    Makes no difference.

    I dont have email access at work but I think when I get home tonight I will send one out complaining about this.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Blurry Menu Images

    Ah its only in WPF 3.5 SP1 and I dont have SP1 installed on my work laptop :doh:
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Blurry Menu Images

    Yeah I was just gonna say but I thought you would have the SP installed so thought it was a bit odd... but obviously that explains it Now if you will excuse me I just need to reboot my PC as changing the resolution to test some WPF'ness has made everything look like cr*p! (even after I have changed it back to what it was originally)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Blurry Menu Images

    Looks like about 2 hours to download and install

    So much for the patch management software they run here lol.

    Guess I will take my laptop home and check out the fixes so I can get back on track.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Blurry Menu Images

    SP-1 installed. Rebooting and will try the new parameter
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Blurry Menu Images

    I had to specify the W + H but now its all sharp looking.

    Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Re: [RESOLVED] Blurry Menu Images

    Hi.

    If you save your pictures with 96DPI they should look ok. The reason WPF upscales and blurs the images is because they are probaly saved using 72DPI.
    WPF always assume 96DPI. That also means your app will look wrong when displayed on a pc with a default system DPI of e.g. 120.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  11. #11

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Blurry Menu Images

    Thanks pax. Yes they were the standard VS images which are 72 dpi.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [RESOLVED] Blurry Menu Images

    Quote Originally Posted by pax View Post
    Hi.

    If you save your pictures with 96DPI they should look ok. The reason WPF upscales and blurs the images is because they are probaly saved using 72DPI.
    WPF always assume 96DPI. That also means your app will look wrong when displayed on a pc with a default system DPI of e.g. 120.
    Technically not true, basically WPF deals with resolution by using 96dpi as its base unit of measurement. This means that your application should always look the same regardless of resolution (custom images excepted).

    If you wanted to be completely anal you could specify a couple of different DPI images and run a simple check to choose which one to use. This of course only applies to raster based images.

    I had heard a rumor that illustrator now has an addon to export native created (in illustrator) images to XAML so you shouldn't have that issue with images made there.

    Also I have heard that a lot of icon companies are now offering illustrator based versions of their icons too so eventually you shouldn't have this problem.

  13. #13
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Re: [RESOLVED] Blurry Menu Images

    Quote Originally Posted by DeanMc View Post
    Technically not true, basically WPF deals with resolution by using 96dpi as its base unit of measurement. This means that your application should always look the same regardless of resolution (custom images excepted).

    If you wanted to be completely anal you could specify a couple of different DPI images and run a simple check to choose which one to use. This of course only applies to raster based images.

    I had heard a rumor that illustrator now has an addon to export native created (in illustrator) images to XAML so you shouldn't have that issue with images made there.

    Also I have heard that a lot of icon companies are now offering illustrator based versions of their icons too so eventually you shouldn't have this problem.
    Based on this : http://www.wpflearningexperience.com/?p=41=1 it appears that WPF actually does take the dpi setting into account. The problem is, that even though an app should look the same wether run on 96dpi or 120 the reality seems to be another. True, wpf scales to the 120dpi setting, but if the monitor is not truely a 120dpi monitor, things will be off. And if your app was originally layed out to match a e.g 94dpi monitor with a dpi setting of 96dpi (like in the link), things will usually be 2% off. When designing your app, you lay things out so they match and look ok. Run that on a 120dpi setting and thing will look very different.

    Anyhow... The original question was about images, and the images have to have the same dpi as the system it's run on. Meaning, that you still have to design your app with one setting in mind and hope that people won't use another setting. I know you can specify the width and height at designtime, but there are cases where images are loaded dynamically. Wpf should use the pixel size of the images instead. At least for raster images.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  14. #14
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [RESOLVED] Blurry Menu Images

    What a good article. I suppose I will have to factor this in when I am designing in future. Rep+ for that!

  15. #15

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Blurry Menu Images

    Great extra info.
    Gonna read the article on lunch. Slave driving work wont let me gold brick lol
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] Blurry Menu Images

    Damn I just read the article and well... I feel conned! I thought WPF's resolution independence meant it would be the same on any resolution
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  17. #17

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Blurry Menu Images

    Maybe they meant that it was "independant" from being independant lol
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width