Skip to content

Bug: PNG-based .ico files render with black background in sidebar and thumbnails #17923

@kalmix

Description

@kalmix

Description

Custom folder icons that use PNG-based .ico files display with a black background instead of transparency in the sidebar and thumbnail previews. This issue does not occur with:

System .dll icons (which render correctly with transparency)
BMP-based .ico files (which also render correctly)

The black background appears specifically when icons are rendered at small scales (such as sidebar icons) or when thumbnails are scaled down using Ctrl+Scrollwheel. The issue is caused by Image.FromHbitmap() not preserving the alpha channel from PNG-based icons when converting from HBITMAP.

Root Cause of the Bug:
The issue appears to be in Win32Helper.Storage.cs in the GetBitmapFromHBitmap method. Image.FromHbitmap doesn't preserve the alpha channel for PNG-based icons, causing transparent pixels to render as black. The existing detection logic (IsAlphaBitmap) may fail for small-scale icons that don't have semi-transparent pixels.

Expected behavior:
The custom folder icon should display with proper transparency, showing no black background.

Actual behavior:
The custom folder icon displays with a black background where transparency should be, particularly in the sidebar and when thumbnails are scaled to smaller sizes.

Note:
I know this issue is related/similar to issue #14993 but this is a variant is for custom .ico (PNG-based) files.

Steps To Reproduce

  1. Create a custom folder icon using a PNG-based .ico file (not BMP-based)
  2. Apply the custom icon to a folder using folder properties
  3. Pin that same folder to the sidebar
  4. Observe the folder icon in the sidebar

Files Version

4.0.21.0

Windows Version

10.0.22631.6199

User ID

7f792b8e-49e5-4005-b360-0e98745a13d0

Log File

debug.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    area - sidebarFeatures or bug reports relating to the sidebararea - thumbnailsFeatures or bug reports relating to thumbnails

    Type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions