< Back
ConvertTo-ImageSource
Post
NAME ConvertTo-ImageSource
SYNOPSIS
Converts a System.Drawing.Icon into a System.Windows.Interop.InteropBitmap.
SYNTAX
ConvertTo-ImageSource [-Icon] <Icon> [<CommonParameters>]
DESCRIPTION
ConvertTo-ImageSource converts a System.Drawing.Icon, which are used in Windows Forms applications, into a
System.Windows.InteropBitmap, a descendent of the ImageSource class used by icons for WPF applications.
PARAMETERS
-Icon <Icon>
The icon to convert into an ImageSource
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.Drawing.Icon
ConvertTo-ImageSource accepts System.Drawing.Icon objects to the Icon parameter binding to the Icon property.
OUTPUTS
System.Windows.Interop.InteropBitmap
ConvertTo-ImageSource outputs a System.Windows.Interop.InteropBitmap object representing the bitmap image.
-------------------------- EXAMPLE 1 --------------------------
PS C:>ConvertTo-ImageSource -Icon $Form.Icon
This command will convert the icon used in the Windows Form $Form into an ImageSource derived bitmap image that
can be used in WPF applications.
-------------------------- EXAMPLE 2 --------------------------
PS C:>Get-IconFromFile -Path setupapi.dll -Index 21 | ConvertTo-ImageSource
This command will get the icon at index 21 from the setupapi.dll and then convert it to an ImageSource derived
bitmap image that can be used in WPF applications.
RELATED LINKS
SYNOPSIS
Converts a System.Drawing.Icon into a System.Windows.Interop.InteropBitmap.
SYNTAX
ConvertTo-ImageSource [-Icon] <Icon> [<CommonParameters>]
DESCRIPTION
ConvertTo-ImageSource converts a System.Drawing.Icon, which are used in Windows Forms applications, into a
System.Windows.InteropBitmap, a descendent of the ImageSource class used by icons for WPF applications.
PARAMETERS
-Icon <Icon>
The icon to convert into an ImageSource
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.Drawing.Icon
ConvertTo-ImageSource accepts System.Drawing.Icon objects to the Icon parameter binding to the Icon property.
OUTPUTS
System.Windows.Interop.InteropBitmap
ConvertTo-ImageSource outputs a System.Windows.Interop.InteropBitmap object representing the bitmap image.
-------------------------- EXAMPLE 1 --------------------------
PS C:>ConvertTo-ImageSource -Icon $Form.Icon
This command will convert the icon used in the Windows Form $Form into an ImageSource derived bitmap image that
can be used in WPF applications.
-------------------------- EXAMPLE 2 --------------------------
PS C:>Get-IconFromFile -Path setupapi.dll -Index 21 | ConvertTo-ImageSource
This command will get the icon at index 21 from the setupapi.dll and then convert it to an ImageSource derived
bitmap image that can be used in WPF applications.
RELATED LINKS