Results 1 to 15 of 15

Thread: TIP: Large Icon Parsing for Win10+

  1. #1

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Resolved TIP: Large Icon Parsing for Win10+

    This may only apply to you that have your own icon parsing routines.

    We all know that starting with Vista, 256x256 icons are supported and in PNG format, contained within an icon structure. Well, Win10 introduced 768x768 icon support and, theoretically, any size can be supported now.

    Before Win10, we just assumed that 256x256 was largest supported in the icon format. When parsing the icon directory structure and we saw icon dimensions of 0x0, we translated that to 256x256. To support icons greater than 256x256, the icon structure assumptions changed.

    If you see 0x0 dimensions, you'll want to jump to the data section of the icon and verify it contains either a BMP or PNG header. From that header, parse out the true dimensions. Many parsers out there do this anyway since most of us were not convinced the icon structure was always created properly, but many parsers would abort/ignore if the size was greater than 256x256 because a) system wouldn't support that b) assumption of corruption/malformation. Obviously you'll need to be aware of system restrictions if calling APIs to create the icon, but if manually displaying it, then system restrictions are not in play.

    Of course, you cannot easily add these to the icon section of the VB resource file.
    Last edited by LaVolpe; Jan 28th, 2015 at 08:31 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,442

    Re: TIP: Large Icon Parsing for Win10+

    Hey LaVolpe...maybe should be posted in Code Bank????

  3. #3

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    Quote Originally Posted by SamOscarBrown View Post
    Hey LaVolpe...maybe should be posted in Code Bank????
    Maybe, this will be short-lived and is just a heads-up. A better submission in the code bank would be a current/proper icon parsing routine. Hint, hint

    Edited:
    I don't have Win10, but one question I'd be curious about: If app is not manifested to say it supports Win10, will the APIs create a 768x768 icon? Reason for the question is that, the system without the proper manifest will report it as a lower operating system when queried. Even though Windows is not telling the truth there, does it actually/intentionally restrict users to that lower reported O/S functionality?

    If anyone with Win10 wants to confirm this, I can supply a 768x768 icon (if you can't find one). LoadImage and/or CreateIconFromResource APIs can be used to create the icon.
    Last edited by LaVolpe; Jan 28th, 2015 at 08:41 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,442

    Re: TIP: Large Icon Parsing for Win10+

    If I had YOUR talent/knowledge, I'd write the icon parsing routine...but, I don't.

  5. #5
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    557

    Re: TIP: Large Icon Parsing for Win10+

    I am sorry, schedule too tight till the end of the week to get into some involving matter (such as manifests and icon parsing), but it you have some ready made stuff to run and check on win 10 , I can do that.

  6. #6

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    Quote Originally Posted by Navion View Post
    I am sorry, schedule too tight till the end of the week to get into some involving matter (such as manifests and icon parsing), but it you have some ready made stuff to run and check on win 10 , I can do that.
    I'll get back to you in the early evening. I'll upload/zip a suitable 768x768 icon, manifest and sample project. Thanx.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    @Navion. Never mind. On Vista, I can create a 768x768 icon. Had to try it just for the heck of it. Therefore, logic dictates (yep, I know) that Win7+ will also create them regardless of the O/S.

    Edited...
    If anyone else wants to mess with these, I've attached a 256x256 & 768x768 icon.
    As for my tests:
    1) Use LoadImage to create the icon with LR_LOADFROMFILE flag
    2) Use GetIconInfo on the returned handle
    3) Use API GetObject on the hbmColor member of the IconInfo structure, passing a BITMAP structure
    4) Validate the icon size via the BITMAP structure's bmWidth & bmHeight members
    The 256x256 icon is provided for comparison. If you load that one @ 768x768 you will notice quite a bit of difference in quality vs the 768x768 icon provided.
    Attached Files Attached Files
    Last edited by LaVolpe; Jan 28th, 2015 at 06:00 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    256

    Re: TIP: Large Icon Parsing for Win10+

    Interesting.

    Thanks for the uploading. I have had a quick test of the 768x768 one and found that I didn't have to do anything to the existing code, except to block the "for safety" lines:

    If w > 256 then w = 256
    If h > 256 then h = 256

    I use GDIplus, i.e. after parsing headers, just pass the extracted PNG bytes to GDIplus.

    Have you got one with varied sizes and color depths? I wish to see if my existing code can handle a multi-item file without any revision.

  9. #9

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    Quote Originally Posted by Brenker View Post
    Have you got one with varied sizes and color depths? I wish to see if my existing code can handle a multi-item file without any revision.
    Sorry, not on hand, been meaning to build one with lots of different depths/sizes just for testing reasons; just not got around to it.

    However, if you do search the web a bit, you could find some but generally not all inclusive with what I'm sure you are after.

    P.S. Not sure about the latest versions of GDI+ (Win7+), but GDI+ has had issues with some non-png encoded icons in the past. 24bpp comes to mind
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    256

    Re: TIP: Large Icon Parsing for Win10+

    That is okay, never mind, we surely will get some as time moves on.

    Basically there shouldn't be too much work involved. It is just that running a live sample file it would be easier to spot which code lines need a modification, such as "If w = 256 Then" be changed to "If w >= 256 Then", this kind of work.

    Regarding 24-BPP items on Win 7, I haven't bumped into any problem. As you know, Win 7 ICO files themselves don't have 24-BPP items, so a while back for testing purposes I added 24-BPP ones to an existing Win 7 multi-item ICO file, 256x256 one being PNG and rest ICO, all are fine on Win 7.

    The other day I bumped into an interesting 16-bit PNG in
    http://entropymine.com/jason/testbed/pngtrans/
    (attached). GDIplus on Win 7 displays the image right, but not the older one - the older one would show the middle portion on left as transparent as well, while the correct display should be only the right half has transparency. If one procesess it oneself, not using GDIplus, an extra step is needed because after conversion from 16-bit to 8-bit, some non-transparent pixels get the same color as the designated transparent color. See if you are interested in playing with it.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Brenker; Jan 29th, 2015 at 04:19 PM. Reason: Attach screenshot

  11. #11
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    256

    Re: TIP: Large Icon Parsing for Win10+

    I've now made a multi-item one, for testing purposes. This ICO file has the following items inside:

    8-BPP ones:

    256x256 PNG, 64x64 ICO, 32x32 ICO

    and 32-BPP ones:

    768x768 PNG, 512x512 PNG, 256x256 PNG, 64x64 ICO, 32x32 ICO.
    Attached Files Attached Files
    Last edited by Brenker; Mar 19th, 2015 at 11:01 AM. Reason: Found that 8-BPP 256x256 one with chessboard in image, replaced for good order sake

  12. #12

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    Brenker, I'll review it & probably add others. I still want to support icons that Windows supports & that also includes these bit depths: 1, 4, 16, & 24.

    I've also wanted to see if Windows will actually create say a 32x32 png-encoded icon. Just curious. And if it does create it, will it actually use it in the selection process when extracting from app's compiled resources.

    Edited: Regarding that 16bpp PNG... Vista displays it correctly on desktop & image/fax viewer, but using GDI+ and VB, it is rendered to a hDC with the middle transparent. Interesting.
    Last edited by LaVolpe; Jan 29th, 2015 at 10:11 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    256

    Re: TIP: Large Icon Parsing for Win10+

    For good order sake I come back to clarfiy a point.

    LaVolpe is right in saying that there is a GDIplus bug in dealing with 24-BPP icon items, if GDIplus version is an older one, i.e. before Win 7. There are other irregularities as well:

    If BPP = 1, in order for GDIplus to process properly, one has to ensure image and mask are matched, as sometimes an icon/cursor file may have mask all white or all black.

    GDIplus below Win 7 doesn't honour alpha bytes for icon items. This means one has to plug in alpha values in 4th bytes of a DIB.

    All the above need some patches in handling the bytes passed to GDIplus, or on returning from GDIplus.

  14. #14

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,473

    Re: TIP: Large Icon Parsing for Win10+

    @Brenker. With any routines I wrote regarding icons/cursors and GDI+, I've always manually parsed the icon & created a 24/32bpp bitmap instead and then transferred the icon bits to the bitmap, in the proper format
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  15. #15
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    256

    Re: TIP: Large Icon Parsing for Win10+

    In posting #11, 8-BPP 256x256 PNG item in the original multi-item ICO file had chessboard background in image. For good order sake, replaced now.

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