Freigeben über


ImageThemingUtilities Class

Definition

Class containing utility methods for grayscaling and transforming color spaces within images.

public ref class ImageThemingUtilities abstract sealed
public ref class ImageThemingUtilities abstract sealed
class ImageThemingUtilities abstract sealed
public static class ImageThemingUtilities
type ImageThemingUtilities = class
Public Module ImageThemingUtilities
Inheritance
ImageThemingUtilities

Fields

ImageBackgroundColorProperty

Gets or sets the Color used for image theming. This target color is used to map the "halo" color in an image with the target background color. This value should be attached on the same UIElement that the Background color is set on when images are drawn directly on that Background. The reason Background is not used directly is twofold:

  1. Backgrounds which are set to Transparent would require a visual tree walk to find the real background.
  2. Background is a Brush, not a Color, which would require interpretation to arrive at a Color instead.
  3. The ultimate background the image is drawn on may not be the desired image to use for theming, for example when a selection brush is conditionally shown in a TreeView.
ThemeScrollBarsProperty

Controls whether the ScrollBars of this element and its descendants have themed scrollbars:

True - ScrollBars are themed False - ScrollBars are not themed null - ScrollBar theme state is inherited

Attached to FrameworkElement

Properties

EnhanceContrastIfNecessaryByDefault
IsImageThemingEnabled

Indicates whether image theming is enabled.

Attached Properties

ImageBackgroundColor

Gets or sets the color used for image theming. The target color is used to map the "halo" color in an image with the target background color. It should be attached on the same UIElement that the gackground color is set on when images are drawn directly on that Background. The reasons why the background is not used directly:1. Backgrounds that are set to Transparent would require a visual tree walk to find the real background.2. The background is a Brush, not a Color, which would require interpretation to arrive at a Color instead.3. The ultimate background the image is drawn on may not be the desired image to use for theming, for example when a selection brush is conditionally shown in a TreeView.

ThemeScrollBars

Controls whether the ScrollBars of this element and its descendants have themed scrollbars. It is attached to FrameworkElementTrue - ScrollBars are themedFalse - ScrollBars are not themednull - ScrollBar theme state is inherited

Methods

ClearOptOutPixel(Byte[], Int32, Int32, Boolean)

Clears the opt-out pixel in a bitmap, making it black for a 24-bit or less bitmap and transparent for a 32-bit bitmap with transparency. Bitmaps that have a separate mask must deal with updating the mask bitmap themselves.

ClearOptOutPixel(Byte*, Int32, Int32, Boolean)
ClearWeakImageCache()
GetImageBackgroundColor(DependencyObject)

Gets the ImageBackgroundColor property.

GetOrCreateThemedBitmapSource(BitmapSource, Color, Boolean, Color, Boolean, Boolean)

Converts an input BitmapSource into an BitmapSource that blends in with the target background. This converter performs two conversions.

  1. The luminosity of the image is transformed so that the constant "halo" luminosity blends in with the background. This has the effect of eliminating the halo visually. The "halo" luminosity is an immutable constant, and is not calculated from the input image.
  2. The image is converted to grayscale if the isEnabled parameter is false. This uses the "biasColor" to determine how to transform the image to grayscale.
GetOrCreateThemedBitmapSource(BitmapSource, Color, Boolean, Color, Boolean)

Converts an input BitmapSource into an BitmapSource that blends in with the target background. This converter performs two conversions.

  1. The luminosity of the image is transformed so that the constant "halo" luminosity blends in with the background. This has the effect of eliminating the halo visually. The "halo" luminosity is an immutable constant, and is not calculated from the input image.
  2. The image is converted to grayscale if the isEnabled parameter is false. This uses the "biasColor" to determine how to transform the image to grayscale.
GetOrCreateThemedBitmapSource(BitmapSource, Color, Boolean, Color)

Converts an input BitmapSource into an BitmapSource that blends in with the target background. This converter performs two conversions.

  1. The luminosity of the image is transformed so that the constant "halo" luminosity blends in with the background. This has the effect of eliminating the halo visually. The "halo" luminosity is an immutable constant, and is not calculated from the input image.
  2. The image is converted to grayscale if the isEnabled parameter is false. This uses the "biasColor" to determine how to transform the image to grayscale.
GetThemedBitmap(Bitmap, Color, Boolean)

Creates a new Bitmap, based on the input one, but the new one blends in with the target background.

GetThemedBitmap(Bitmap, Color)

Creates a new Bitmap, based on the input one, but the new one blends in with the target background.

GetThemedBitmap(Bitmap, UInt32, Boolean)

Creates a new Bitmap, based on the input one, but the new one blends in with the target background.

GetThemedBitmap(Bitmap, UInt32)

Creates a new Bitmap, based on the input one, but the new one blends in with the target background.

GetThemeScrollBars(DependencyObject)

Gets the ThemeScrollbarsProperty value.

GrayscaleDIBits(Byte[], Int32, Color)

Transforms a BGRA32 device-independent bitmap to grayscale.

IsDark(Color)

Indicates whether the given color is "dark", based on luminosity and how the color contrasts with black/white.

IsLight(Color)

Indicates whether the given color is "dark", based on luminosity and how the color contrasts with black/white.

IsOptOutPixelSet(Byte[], Int32, Int32, Boolean)

Determines if the opt-out pixel is set for a bitmap. Cyan is the sentinel color for opting out of icon inversion. If this pixel is set in the image, then icon inversion is disabled, and the image should not be inverted.

IsOptOutPixelSet(Byte*, Int32, Int32, Boolean)
ModifyBitmap(BitmapSource, ImageThemingUtilities+ModifyPixelCallback)

Modifies a BitmapSource using a callback which recieves the raw pixel data from the BitmapSource, creating a new BitmapSource if changes were made.

SetImageBackgroundColor(DependencyObject, Color)

Sets the ImageBackgroundColor property.

SetOptOutPixel(BitmapSource)

Adds a marker that will prevent ImageThemingUtilities.ThemeDIBits from theming the image a drawing context. The marker is a pixel in the top-right corner of the image that is set to #FF00FFFF.

SetOptOutPixel(Byte[], Int32, Int32, Boolean)

Sets the opt-out pixel in a bitmap.

SetOptOutPixel(Byte*, Int32, Int32, Boolean)
SetThemeScrollBars(DependencyObject, Nullable<Boolean>)

Sets the ThemeScrollbarsProperty value.

ThemeDIBits(Int32, Byte[], Int32, Int32, Boolean, UInt32, Boolean, Boolean)

Transforms the given RGBA32 device-independent bitmap bits to try to match the fixed halo luminosity to the background luminosity (see TransformLuminosity).

ThemeDIBits(Int32, Byte[], Int32, Int32, Boolean, UInt32, Boolean)

Transforms the given RGBA32 device-independent bitmap bits to try to match the fixed halo luminosity to the background luminosity (see TransformLuminosity).

ThemeDIBits(Int32, Byte[], Int32, Int32, Boolean, UInt32)

Transforms the given RGBA32 device-independent bitmap bits to try to match the fixed halo luminosity to the background luminosity (see TransformLuminosity).

ThemePixel(Byte, Byte, Byte, HslColor, Boolean)

Themes the R, G, and B components of an individual pixel.

ThemePixel(Byte, Byte, Byte, HslColor)

Themes the R, G, and B components of an individual pixel.

ThemePixelWithExtraContrast(Byte, Byte, Byte, HslColor)

Themes the R, G, and B components of an individual pixel. Use this if the results from ThemePixel(Byte, Byte, Byte, HslColor, Boolean) result in insufficient contrast with the background.

Events

ThemeScrollBarsChanged

Raised with the ThemeScrollBars property changes on a dependency object

Applies to