Skip to content

Conversation

@kalmix
Copy link
Contributor

@kalmix kalmix commented Dec 2, 2025

Resolved / Related Issues

What was wrong
Custom folder icons using PNG-based .ico files displayed with a black background instead of transparency in the sidebar and thumbnail previews. The issue occurred specifically when:

  • Icons were rendered at small scales (sidebar icons) and Tab icon.
  • Thumbnails were scaled down using Ctrl+Scrollwheel
  • The .ico file was PNG-based.

Root Cause
The IsAlphaBitmap() method in Win32Helper.Storage.cs only detected semi-transparent pixels (0 < alpha < 255) but missed fully transparent pixels (alpha = 0).

// Only detected semi-transparent pixels
if (pixelColor.A > 0 & pixelColor.A < 255)
    return true;

The Fix
Changed the alpha detection condition to catch all non-opaque pixels:

if (pixelColor.A < 255)
    return true;

This ensures that any pixel with transparency (including alpha = 0) is detected, triggering the proper alpha bitmap conversion that preserves transparency.

Before and After Screenshots:

Before After
BEFORE AFTER

Steps used to test these changes

  1. Opened Files
  2. Created a custom folder icon using a PNG-based .ico file with transparent background
  3. Applied the icon to a folder via folder properties
  4. Pinned the folder to the sidebar
  5. Verified the icon displays with proper transparency
  6. Scaled thumbnails down using Ctrl+Scrollwheel
  7. Confirmed transparency is preserved at all sizes
  8. Tested with BMP-based .ico files to ensure no regression
  9. Tested with system .dll icons to confirm they still work correctly

@yaira2
Copy link
Member

yaira2 commented Dec 3, 2025

Does this have any impact for #14993?

@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Dec 3, 2025
@kalmix
Copy link
Contributor Author

kalmix commented Dec 3, 2025

@yaira2 Yes, this change fixes that issue too. I've tested the change using the imageres.dll of a Windows 10 build.

Before
image

After
image

In the related issue (#14993) some icons do work with the old code, because they contain semi-transparent pixels (0<α<255) but for other icons such as the desktop icon that doesn't have any semi-transparent pixels the bug will appear.

Copy link
Member

@yaira2 yaira2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Dec 3, 2025
@yaira2 yaira2 changed the title Fix: PNG-based .ico files rendering with black background (#17923) Fix: PNG-based .ico files rendering with black background Dec 3, 2025
@yaira2 yaira2 changed the title Fix: PNG-based .ico files rendering with black background Fix: Fixed PNG-based .ico files rendering with black background Dec 3, 2025
@yaira2 yaira2 changed the title Fix: Fixed PNG-based .ico files rendering with black background Fix: Fixed PNG-based .ico files rendering with black backgrounds Dec 3, 2025
@yaira2 yaira2 merged commit 4abd5f2 into files-community:main Dec 3, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants