ImageAttributes ImageAttributes ImageAttributes ImageAttributes Class

定義

包含如何在呈現期間操作點陣圖和中繼檔色彩的相關資訊。Contains information about how bitmap and metafile colors are manipulated during rendering.

public ref class ImageAttributes sealed : ICloneable, IDisposable
public sealed class ImageAttributes : ICloneable, IDisposable
type ImageAttributes = class
    interface ICloneable
    interface IDisposable
Public NotInheritable Class ImageAttributes
Implements ICloneable, IDisposable
繼承
ImageAttributesImageAttributesImageAttributesImageAttributes
實作

範例

下列範例會為所有的一種色彩 (0.2,0.0、 0.4,1.0) 的映像和雙精度浮點數的紅色元件會加入紅色、 綠色和藍色元件中的 0.2The following example takes an image that is all one color (0.2, 0.0, 0.4, 1.0) and doubles the red component adds 0.2 to the red, green, and blue components

下圖顯示原始的映像,在左邊和轉換後的映像,在右邊。The following illustration shows the original image on the left and the transformed image on the right.

色彩Colors

下列範例中的程式碼會使用下列步驟執行的重新著色:The code in the following example uses the following steps to perform the recoloring:

  1. 初始化ColorMatrix物件。Initialize a ColorMatrix object.

  2. 建立ImageAttributes物件,並傳遞ColorMatrix物件SetColorMatrix方法ImageAttributes物件。Create an ImageAttributes object and pass the ColorMatrix object to the SetColorMatrix method of the ImageAttributes object.

  3. 傳遞ImageAttributes物件至DrawImage方法Graphics物件。Pass the ImageAttributes object to the DrawImage method of a Graphics object.

Image image = new Bitmap("InputColor.bmp");
ImageAttributes imageAttributes = new ImageAttributes();
int width = image.Width;
int height = image.Height;

float[][] colorMatrixElements = { 
   new float[] {2,  0,  0,  0, 0},        // red scaling factor of 2
   new float[] {0,  1,  0,  0, 0},        // green scaling factor of 1
   new float[] {0,  0,  1,  0, 0},        // blue scaling factor of 1
   new float[] {0,  0,  0,  1, 0},        // alpha scaling factor of 1
   new float[] {.2f, .2f, .2f, 0, 1}};    // three translations of 0.2

ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);

imageAttributes.SetColorMatrix(
   colorMatrix,
   ColorMatrixFlag.Default,
   ColorAdjustType.Bitmap);

e.Graphics.DrawImage(image, 10, 10);

e.Graphics.DrawImage(
   image,
   new Rectangle(120, 10, width, height),  // destination rectangle 
   0, 0,        // upper-left corner of source rectangle 
   width,       // width of source rectangle
   height,      // height of source rectangle
   GraphicsUnit.Pixel,
   imageAttributes);
Dim image As New Bitmap("InputColor.bmp")
Dim imageAttributes As New ImageAttributes()
Dim width As Integer = image.Width
Dim height As Integer = image.Height

' The following matrix consists of the following transformations:
' red scaling factor of 2
' green scaling factor of 1
' blue scaling factor of 1
' alpha scaling factor of 1
' three translations of 0.2
Dim colorMatrixElements As Single()() = { _
   New Single() {2, 0, 0, 0, 0}, _
   New Single() {0, 1, 0, 0, 0}, _
   New Single() {0, 0, 1, 0, 0}, _
   New Single() {0, 0, 0, 1, 0}, _
   New Single() {0.2F, 0.2F, 0.2F, 0, 1}}

Dim colorMatrix As New ColorMatrix(colorMatrixElements)

imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap)

e.Graphics.DrawImage(image, 10, 10)

e.Graphics.DrawImage( _
   image, _
   New Rectangle(120, 10, width, height), _
   0, _
   0, _
   width, _
   height, _
   GraphicsUnit.Pixel, _
   imageAttributes)

備註

ImageAttributes物件會維護數個彩色調整設定,包括彩色調整矩陣、 灰階調整矩陣、 gamma 修正值、 色彩對應資料表,以及色彩臨界值。An ImageAttributes object maintains several color-adjustment settings, including color-adjustment matrices, grayscale-adjustment matrices, gamma-correction values, color-map tables, and color-threshold values. 在呈現期間,色彩可以更正、 變黑、 淡化,並移除。During rendering, colors can be corrected, darkened, lightened, and removed. 若要套用這類的操作,初始化ImageAttributes物件,並傳遞該路徑ImageAttributes物件 (以及路徑Image) 來DrawImage方法。To apply such manipulations, initialize an ImageAttributes object and pass the path of that ImageAttributes object (along with the path of an Image) to the DrawImage method.

建構函式

ImageAttributes() ImageAttributes() ImageAttributes() ImageAttributes()

初始化 ImageAttributes 類別的新執行個體。Initializes a new instance of the ImageAttributes class.

方法

ClearBrushRemapTable() ClearBrushRemapTable() ClearBrushRemapTable() ClearBrushRemapTable()

清除此 ImageAttributes 物件的筆刷色彩重新對應表。Clears the brush color-remap table of this ImageAttributes object.

ClearColorKey() ClearColorKey() ClearColorKey() ClearColorKey()

清除預設分類的色鍵 (透明度範圍)。Clears the color key (transparency range) for the default category.

ClearColorKey(ColorAdjustType) ClearColorKey(ColorAdjustType) ClearColorKey(ColorAdjustType) ClearColorKey(ColorAdjustType)

清除指定分類的色鍵 (透明度範圍)。Clears the color key (transparency range) for a specified category.

ClearColorMatrix() ClearColorMatrix() ClearColorMatrix() ClearColorMatrix()

清除預設分類的色彩調整矩陣。Clears the color-adjustment matrix for the default category.

ClearColorMatrix(ColorAdjustType) ClearColorMatrix(ColorAdjustType) ClearColorMatrix(ColorAdjustType) ClearColorMatrix(ColorAdjustType)

清除指定分類的彩色調整矩陣。Clears the color-adjustment matrix for a specified category.

ClearGamma() ClearGamma() ClearGamma() ClearGamma()

停用預設分類的 Gamma 修正。Disables gamma correction for the default category.

ClearGamma(ColorAdjustType) ClearGamma(ColorAdjustType) ClearGamma(ColorAdjustType) ClearGamma(ColorAdjustType)

停用指定分類的 Gamma 修正。Disables gamma correction for a specified category.

ClearNoOp() ClearNoOp() ClearNoOp() ClearNoOp()

清除預設分類的 NoOp 設定。Clears the NoOp setting for the default category.

ClearNoOp(ColorAdjustType) ClearNoOp(ColorAdjustType) ClearNoOp(ColorAdjustType) ClearNoOp(ColorAdjustType)

清除指定分類的 NoOp 設定。Clears the NoOp setting for a specified category.

ClearOutputChannel() ClearOutputChannel() ClearOutputChannel() ClearOutputChannel()

清除預設分類的 CMYK (青色-洋紅-黃色-黑色) 輸出色頻設定。Clears the CMYK (cyan-magenta-yellow-black) output channel setting for the default category.

ClearOutputChannel(ColorAdjustType) ClearOutputChannel(ColorAdjustType) ClearOutputChannel(ColorAdjustType) ClearOutputChannel(ColorAdjustType)

清除指定分類的 (青色-洋紅-黃色-黑色) 輸出色頻設定。Clears the (cyan-magenta-yellow-black) output channel setting for a specified category.

ClearOutputChannelColorProfile() ClearOutputChannelColorProfile() ClearOutputChannelColorProfile() ClearOutputChannelColorProfile()

清除預設分類之輸出通道色彩設定檔的設定。Clears the output channel color profile setting for the default category.

ClearOutputChannelColorProfile(ColorAdjustType) ClearOutputChannelColorProfile(ColorAdjustType) ClearOutputChannelColorProfile(ColorAdjustType) ClearOutputChannelColorProfile(ColorAdjustType)

清除指定分類之輸出色頻色彩設定檔的設定。Clears the output channel color profile setting for a specified category.

ClearRemapTable() ClearRemapTable() ClearRemapTable() ClearRemapTable()

清除預設分類的色彩重新對應表。Clears the color-remap table for the default category.

ClearRemapTable(ColorAdjustType) ClearRemapTable(ColorAdjustType) ClearRemapTable(ColorAdjustType) ClearRemapTable(ColorAdjustType)

清除指定分類的色彩重新對應表。Clears the color-remap table for a specified category.

ClearThreshold() ClearThreshold() ClearThreshold() ClearThreshold()

清除預設分類的閾值。Clears the threshold value for the default category.

ClearThreshold(ColorAdjustType) ClearThreshold(ColorAdjustType) ClearThreshold(ColorAdjustType) ClearThreshold(ColorAdjustType)

清除指定分類的閾值。Clears the threshold value for a specified category.

Clone() Clone() Clone() Clone()

建立這個 ImageAttributes 物件的完全相同複本。Creates an exact copy of this ImageAttributes object.

Dispose() Dispose() Dispose() Dispose()

釋放這個 ImageAttributes 物件使用的所有資源。Releases all resources used by this ImageAttributes object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetAdjustedPalette(ColorPalette, ColorAdjustType) GetAdjustedPalette(ColorPalette, ColorAdjustType) GetAdjustedPalette(ColorPalette, ColorAdjustType) GetAdjustedPalette(ColorPalette, ColorAdjustType)

根據指定分類的調整設定來調整調色盤 (Palette) 中的色彩。Adjusts the colors in a palette according to the adjustment settings of a specified category.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
SetBrushRemapTable(ColorMap[]) SetBrushRemapTable(ColorMap[]) SetBrushRemapTable(ColorMap[]) SetBrushRemapTable(ColorMap[])

設定筆刷分類的色彩重新對應表。Sets the color-remap table for the brush category.

SetColorKey(Color, Color) SetColorKey(Color, Color) SetColorKey(Color, Color) SetColorKey(Color, Color)

設定預設分類的色鍵。Sets the color key for the default category.

SetColorKey(Color, Color, ColorAdjustType) SetColorKey(Color, Color, ColorAdjustType) SetColorKey(Color, Color, ColorAdjustType) SetColorKey(Color, Color, ColorAdjustType)

設定指定分類的色鍵 (透明度範圍)。Sets the color key (transparency range) for a specified category.

SetColorMatrices(ColorMatrix, ColorMatrix) SetColorMatrices(ColorMatrix, ColorMatrix) SetColorMatrices(ColorMatrix, ColorMatrix) SetColorMatrices(ColorMatrix, ColorMatrix)

設定預設分類的彩色調整矩陣和灰階調整矩陣。Sets the color-adjustment matrix and the grayscale-adjustment matrix for the default category.

SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag)

設定預設分類的彩色調整矩陣和灰階調整矩陣。Sets the color-adjustment matrix and the grayscale-adjustment matrix for the default category.

SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag, ColorAdjustType)

設定指定分類的色彩調整矩陣和灰階調整矩陣。Sets the color-adjustment matrix and the grayscale-adjustment matrix for a specified category.

SetColorMatrix(ColorMatrix) SetColorMatrix(ColorMatrix) SetColorMatrix(ColorMatrix) SetColorMatrix(ColorMatrix)

設定預設分類的彩色調整矩陣。Sets the color-adjustment matrix for the default category.

SetColorMatrix(ColorMatrix, ColorMatrixFlag) SetColorMatrix(ColorMatrix, ColorMatrixFlag) SetColorMatrix(ColorMatrix, ColorMatrixFlag) SetColorMatrix(ColorMatrix, ColorMatrixFlag)

設定預設分類的彩色調整矩陣。Sets the color-adjustment matrix for the default category.

SetColorMatrix(ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrix(ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrix(ColorMatrix, ColorMatrixFlag, ColorAdjustType) SetColorMatrix(ColorMatrix, ColorMatrixFlag, ColorAdjustType)

設定指定分類的彩色調整矩陣。Sets the color-adjustment matrix for a specified category.

SetGamma(Single) SetGamma(Single) SetGamma(Single) SetGamma(Single)

設定預設分類的 Gamma 值。Sets the gamma value for the default category.

SetGamma(Single, ColorAdjustType) SetGamma(Single, ColorAdjustType) SetGamma(Single, ColorAdjustType) SetGamma(Single, ColorAdjustType)

設定指定分類的 Gamma 值。Sets the gamma value for a specified category.

SetNoOp() SetNoOp() SetNoOp() SetNoOp()

關閉預設分類的色彩調整。Turns off color adjustment for the default category. 您可以呼叫 ClearNoOp 方法,以重新啟用在呼叫 SetNoOp 方法之前既有的彩色調整設定。You can call the ClearNoOp method to reinstate the color-adjustment settings that were in place before the call to the SetNoOp method.

SetNoOp(ColorAdjustType) SetNoOp(ColorAdjustType) SetNoOp(ColorAdjustType) SetNoOp(ColorAdjustType)

關閉指定分類的彩色調整。Turns off color adjustment for a specified category. 您可以呼叫 ClearNoOp 方法,以重新啟用在呼叫 SetNoOp 方法之前既有的彩色調整設定。You can call the ClearNoOp method to reinstate the color-adjustment settings that were in place before the call to the SetNoOp method.

SetOutputChannel(ColorChannelFlag) SetOutputChannel(ColorChannelFlag) SetOutputChannel(ColorChannelFlag) SetOutputChannel(ColorChannelFlag)

設定預設分類的 CMYK (青色-洋紅-黃色-黑色) 輸出色頻。Sets the CMYK (cyan-magenta-yellow-black) output channel for the default category.

SetOutputChannel(ColorChannelFlag, ColorAdjustType) SetOutputChannel(ColorChannelFlag, ColorAdjustType) SetOutputChannel(ColorChannelFlag, ColorAdjustType) SetOutputChannel(ColorChannelFlag, ColorAdjustType)

設定指定分類的 CMYK (青色-洋紅-黃色-黑色) 輸出色頻。Sets the CMYK (cyan-magenta-yellow-black) output channel for a specified category.

SetOutputChannelColorProfile(String) SetOutputChannelColorProfile(String) SetOutputChannelColorProfile(String) SetOutputChannelColorProfile(String)

設定預設分類的輸出通道色彩設定檔案。Sets the output channel color-profile file for the default category.

SetOutputChannelColorProfile(String, ColorAdjustType) SetOutputChannelColorProfile(String, ColorAdjustType) SetOutputChannelColorProfile(String, ColorAdjustType) SetOutputChannelColorProfile(String, ColorAdjustType)

設定指定分類的輸出色頻色彩設定檔案。Sets the output channel color-profile file for a specified category.

SetRemapTable(ColorMap[]) SetRemapTable(ColorMap[]) SetRemapTable(ColorMap[]) SetRemapTable(ColorMap[])

設定預設分類的色彩重新對應表。Sets the color-remap table for the default category.

SetRemapTable(ColorMap[], ColorAdjustType) SetRemapTable(ColorMap[], ColorAdjustType) SetRemapTable(ColorMap[], ColorAdjustType) SetRemapTable(ColorMap[], ColorAdjustType)

設定指定分類的色彩重新對應表。Sets the color-remap table for a specified category.

SetThreshold(Single) SetThreshold(Single) SetThreshold(Single) SetThreshold(Single)

設定預設分類的閾值 (透明度範圍)。Sets the threshold (transparency range) for the default category.

SetThreshold(Single, ColorAdjustType) SetThreshold(Single, ColorAdjustType) SetThreshold(Single, ColorAdjustType) SetThreshold(Single, ColorAdjustType)

設定指定分類的閾值 (透明度範圍)。Sets the threshold (transparency range) for a specified category.

SetWrapMode(WrapMode) SetWrapMode(WrapMode) SetWrapMode(WrapMode) SetWrapMode(WrapMode)

設定環繞模式 (Wrap Mode),這個模式是用來決定如何橫越形狀或在形狀界限並排紋理。Sets the wrap mode that is used to decide how to tile a texture across a shape, or at shape boundaries. 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

SetWrapMode(WrapMode, Color) SetWrapMode(WrapMode, Color) SetWrapMode(WrapMode, Color) SetWrapMode(WrapMode, Color)

指定用來決定如何橫越形狀或在形狀界限並排紋理的環繞模式和色彩。Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

SetWrapMode(WrapMode, Color, Boolean) SetWrapMode(WrapMode, Color, Boolean) SetWrapMode(WrapMode, Color, Boolean) SetWrapMode(WrapMode, Color, Boolean)

指定用來決定如何橫越形狀或在形狀界限並排紋理的環繞模式和色彩。Sets the wrap mode and color used to decide how to tile a texture across a shape, or at shape boundaries. 當紋理小於它正在填滿的形狀時,紋理會橫越形狀來並排,以便將它填滿。A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱