ImageAttributes 클래스

정의

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

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
상속
ImageAttributes
구현

예제

다음 예제에서는 모두 하나의 색(0.2, 0.0, 0.4, 1.0)인 이미지를 사용하고 빨간색 구성 요소가 빨강, 녹색 및 파란색 구성 요소에 0.2를 추가하는 것을 두 배로 늘립니다.

다음 그림에서는 왼쪽에 원본 이미지, 오른쪽에 변환된 이미지를 보여줍니다.

색 색

예제의 코드는 다음 단계를 사용하여 다시 칠을 수행합니다.

  1. ColorMatrix 개체를 초기화합니다.

  2. ImageAttributes 개체를 만들고 ColorMatrix 개체를 ImageAttributes 개체의 SetColorMatrix 메서드로 전달합니다.

  3. ImageAttributes 개체를 Graphics 개체의 DrawImage 메서드로 전달합니다.

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 색 조정 행렬, 회색조 조정 행렬, 감마 보정 값, 색 맵 테이블 및 색 임계값을 비롯한 여러 색 조정 설정을 유지 관리합니다. 렌더링하는 동안 색을 수정하고, 어둡게 하고, 밝게 하고, 제거할 수 있습니다. 이러한 조작을 적용하려면 개체를 ImageAttributes 초기화하고 해당 ImageAttributes 개체의 경로(의 경로와 함께)를 Image메서드에 DrawImage 전달합니다.

참고

.NET 6 이상 버전에서는 이 형식을 포함하는 System.Drawing.Common 패키지가 Windows 운영 체제에서만 지원됩니다. 플랫폼 간 앱에서 이 형식을 사용하면 컴파일 시간 경고 및 런타임 예외가 발생합니다. 자세한 내용은 Windows에서만 지원되는 System.Drawing.Common을 참조하세요.

생성자

ImageAttributes()

ImageAttributes 클래스의 새 인스턴스를 초기화합니다.

메서드

ClearBrushRemapTable()

ImageAttributes 개체의 브러시 색 다시 매핑 테이블을 지웁니다.

ClearColorKey()

기본 범주에 대한 색상 키(투명도 범위)를 지웁니다.

ClearColorKey(ColorAdjustType)

지정된 범주에 대한 색상 키(투명도 범위)를 지웁니다.

ClearColorMatrix()

기본 범주에 대한 색 조정 매트릭스를 지웁니다.

ClearColorMatrix(ColorAdjustType)

지정된 범주에 대한 색 조정 매트릭스를 지웁니다.

ClearGamma()

기본 범주에 대한 감마 보정을 사용하지 않도록 설정합니다.

ClearGamma(ColorAdjustType)

지정된 범주에 대한 감마 보정을 사용하지 않도록 설정합니다.

ClearNoOp()

기본 범주에 대한 NoOp 설정을 지웁니다.

ClearNoOp(ColorAdjustType)

지정된 범주에 대한 NoOp 설정을 지웁니다.

ClearOutputChannel()

기본 범주에 대한 CMYK(녹청, 자홍, 노랑, 검정) 출력 채널 설정을 지웁니다.

ClearOutputChannel(ColorAdjustType)

지정된 범주에 대한 CMYK(녹청, 자홍, 노랑, 검정) 출력 채널 설정을 지웁니다.

ClearOutputChannelColorProfile()

기본 범주에 대한 출력 채널 색 프로필 설정을 지웁니다.

ClearOutputChannelColorProfile(ColorAdjustType)

지정된 범주에 대한 출력 채널 색 프로필 설정을 지웁니다.

ClearRemapTable()

기본 범주에 대한 색 다시 매핑 테이블을 지웁니다.

ClearRemapTable(ColorAdjustType)

지정된 범주에 대한 색 다시 매핑 테이블을 지웁니다.

ClearThreshold()

기본 범주에 대한 임계값을 지웁니다.

ClearThreshold(ColorAdjustType)

지정된 범주에 대한 임계값을 지웁니다.

Clone()

ImageAttributes 개체의 정확한 복사본을 만듭니다.

Dispose()

ImageAttributes 개체에서 사용하는 리소스를 모두 해제합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Finalize()

가비지 컬렉션이 회수하기 전에 개체가 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다.

GetAdjustedPalette(ColorPalette, ColorAdjustType)

지정된 범주의 조정 설정에 따라 색상표에서 색을 조정합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SetBrushRemapTable(ColorMap[])

브러시 범주에 대한 색 다시 매핑 테이블을 설정합니다.

SetBrushRemapTable(ReadOnlySpan<ColorMap>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetBrushRemapTable(ReadOnlySpan<ValueTuple<Color,Color>>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetColorKey(Color, Color)

기본 범주에 대한 색상 키를 설정합니다.

SetColorKey(Color, Color, ColorAdjustType)

지정된 범주에 대한 색상 키(투명도 범위)를 설정합니다.

SetColorMatrices(ColorMatrix, ColorMatrix)

기본 범주에 대한 색 조정 매트릭스와 회색조 조정 매트릭스를 설정합니다.

SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag)

기본 범주에 대한 색 조정 매트릭스와 회색조 조정 매트릭스를 설정합니다.

SetColorMatrices(ColorMatrix, ColorMatrix, ColorMatrixFlag, ColorAdjustType)

지정된 범주에 대한 색 조정 매트릭스와 회색조 조정 매트릭스를 설정합니다.

SetColorMatrix(ColorMatrix)

기본 범주에 대한 색 조정 매트릭스를 설정합니다.

SetColorMatrix(ColorMatrix, ColorMatrixFlag)

기본 범주에 대한 색 조정 매트릭스를 설정합니다.

SetColorMatrix(ColorMatrix, ColorMatrixFlag, ColorAdjustType)

지정된 범주에 대한 색 조정 매트릭스를 설정합니다.

SetGamma(Single)

기본 범주에 대한 감마 값을 설정합니다.

SetGamma(Single, ColorAdjustType)

지정된 범주에 대한 감마 값을 설정합니다.

SetNoOp()

기본 범주에 대한 색 조정을 해제합니다. SetNoOp 메서드를 호출하기 전의 상태로 색 조정 설정을 복구하려면 ClearNoOp 메서드를 호출합니다.

SetNoOp(ColorAdjustType)

지정된 범주에 대한 색 조정을 해제합니다. SetNoOp 메서드를 호출하기 전의 상태로 색 조정 설정을 복구하려면 ClearNoOp 메서드를 호출합니다.

SetOutputChannel(ColorChannelFlag)

기본 범주에 대한 CMYK(녹청, 자홍, 노랑, 검정) 출력 채널을 설정합니다.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

지정된 범주에 대한 CMYK(녹청, 자홍, 노랑, 검정) 출력 채널을 설정합니다.

SetOutputChannelColorProfile(String)

기본 범주에 대한 출력 채널 색 프로필 파일을 설정합니다.

SetOutputChannelColorProfile(String, ColorAdjustType)

지정된 범주에 대한 출력 채널 색 프로필 파일을 설정합니다.

SetRemapTable(ColorAdjustType, ReadOnlySpan<ColorMap>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetRemapTable(ColorAdjustType, ReadOnlySpan<ValueTuple<Color,Color>>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetRemapTable(ColorMap[])

기본 범주에 대한 색 다시 매핑 테이블을 설정합니다.

SetRemapTable(ColorMap[], ColorAdjustType)

지정된 범주에 대한 색 매핑 변경 테이블을 설정합니다.

SetRemapTable(ReadOnlySpan<ColorMap>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetRemapTable(ReadOnlySpan<ValueTuple<Color,Color>>)

렌더링하는 동안 비트맵과 메타파일 색을 조작하는 방법에 대한 정보가 들어 있습니다.

SetThreshold(Single)

기본 범주에 대한 임계값(투명도 범위)을 설정합니다.

SetThreshold(Single, ColorAdjustType)

지정된 범주에 대한 임계값(투명도 범위)을 설정합니다.

SetWrapMode(WrapMode)

질감을 도형 전체에 또는 도형 경계에 바둑판식으로 배열하는 방법을 결정하는 데 사용되는 랩 모드를 설정합니다. 질감이 채우려는 도형보다 작은 경우에는 채울 도형 전체에 질감이 바둑판식으로 배열됩니다.

SetWrapMode(WrapMode, Color)

질감을 도형 전체에 또는 도형 경계에 바둑판식으로 배열하는 방법을 결정하는 데 사용되는 래핑 모드 및 색을 설정합니다. 질감이 채우려는 도형보다 작은 경우에는 채울 도형 전체에 질감이 바둑판식으로 배열됩니다.

SetWrapMode(WrapMode, Color, Boolean)

질감을 도형 전체에 또는 도형 경계에 바둑판식으로 배열하는 방법을 결정하는 데 사용되는 래핑 모드 및 색을 설정합니다. 질감이 채우려는 도형보다 작은 경우에는 채울 도형 전체에 질감이 바둑판식으로 배열됩니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보