Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/IconPathConverter.cpp (C++)

Code before:
    {
        throw hresult_not_implemented();
    }

    Windows::UI::Xaml::Controls::IconSource _IconSourceWUX(hstring path)
    {
        return _getIconSource<Windows::UI::Xaml::Controls::IconSource>(path);
    }

    Microsoft::UI::Xaml::Controls::IconSource _IconSourceMUX(hstring path)
    {
        return _getIconSource<Microsoft::UI::Xaml::Controls::IconSource>(path);
    }

    winrt::Windows::Graphics::Imaging::SoftwareBitmap _convertToSoftwareBitmap(HICON hicon,
                                                                               winrt::Windows::Graphics::Imaging::BitmapPixelFormat pixelFormat,
                                                                               winrt::Windows::Graphics::Imaging::BitmapAlphaMode alphaMode,
                                                                               IWICImagingFactory* imagingFactory)
    {
        // Load the icon into an IWICBitmap
        wil::com_ptr<IWICBitmap> iconBitmap;
        THROW_IF_FAILED(imagingFactory->CreateBitmapFromHICON(hicon, iconBitmap.put()));

        // Put the IWICBitmap into a SoftwareBitmap. This may fail if WICBitmap's format is not supported by
        // SoftwareBitmap. CreateBitmapFromHICON always creates RGBA8 so we're ok.
        auto softwareBitmap = winrt::capture<winrt::Windows::Graphics::Imaging::SoftwareBitmap>(
            winrt::create_instance<ISoftwareBitmapNativeFactory>(CLSID_SoftwareBitmapNativeFactory),
            &ISoftwareBitmapNativeFactory::CreateFromWICBitmap,
            iconBitmap.get(),
            false);

        // Convert the pixel format and alpha mode if necessary
        if (softwareBitmap.BitmapPixelFormat() != pixelFormat || softwareBitmap.BitmapAlphaMode() != alphaMode)
        {
            softwareBitmap = winrt::Windows::Graphics::Imaging::SoftwareBitmap::Convert(softwareBitmap, pixelFormat, alphaMode);
        }

        return softwareBitmap;
    }

    winrt::Windows::Graphics::Imaging::SoftwareBitmap _getBitmapFromIconFileAsync(const winrt::hstring& iconPath,
                                                                                  int32_t iconIndex,
                                                                                  uint32_t iconSize)
    {
        wil::unique_hicon hicon;
        LOG_IF_FAILED(SHDefExtractIcon(iconPath.c_str(), iconIndex, 0, &hicon, nullptr, iconSize));

        if (!hicon)
        {
            return nullptr;
        }

Review comment (suggestion):
```suggestion
        auto softwareBitmap = winrt::capture<SoftwareBitmap>(
```
nit: you're already using the namespace above so might as well take advantage of it haha

Code after:
    {
        throw hresult_not_implemented();
    }

    Windows::UI::Xaml::Controls::IconSource _IconSourceWUX(hstring path)
    {
        return _getIconSource<Windows::UI::Xaml::Controls::IconSource>(path);
    }

    Microsoft::UI::Xaml::Controls::IconSource _IconSourceMUX(hstring path)
    {
        return _getIconSource<Microsoft::UI::Xaml::Controls::IconSource>(path);
    }

    SoftwareBitmap _convertToSoftwareBitmap(HICON hicon,
                                            BitmapPixelFormat pixelFormat,
                                            BitmapAlphaMode alphaMode,
                                            IWICImagingFactory* imagingFactory)
    {
        // Load the icon into an IWICBitmap
        wil::com_ptr<IWICBitmap> iconBitmap;
        THROW_IF_FAILED(imagingFactory->CreateBitmapFromHICON(hicon, iconBitmap.put()));

        // Put the IWICBitmap into a SoftwareBitmap. This may fail if WICBitmap's format is not supported by
        // SoftwareBitmap. CreateBitmapFromHICON always creates RGBA8 so we're ok.
        auto softwareBitmap = winrt::capture<SoftwareBitmap>(
            winrt::create_instance<ISoftwareBitmapNativeFactory>(CLSID_SoftwareBitmapNativeFactory),
            &ISoftwareBitmapNativeFactory::CreateFromWICBitmap,
            iconBitmap.get(),
            false);

        // Convert the pixel format and alpha mode if necessary
        if (softwareBitmap.BitmapPixelFormat() != pixelFormat || softwareBitmap.BitmapAlphaMode() != alphaMode)
        {
            softwareBitmap = SoftwareBitmap::Convert(softwareBitmap, pixelFormat, alphaMode);
        }

        return softwareBitmap;
    }

    SoftwareBitmap _getBitmapFromIconFileAsync(const winrt::hstring& iconPath,
                                               int32_t iconIndex,
                                               uint32_t iconSize)
    {
        wil::unique_hicon hicon;
        LOG_IF_FAILED(SHDefExtractIcon(iconPath.c_str(), iconIndex, 0, &hicon, nullptr, iconSize));

        if (!hicon)
        {
            return nullptr;
        }