다음을 통해 공유


ImageAttributes::ClearColorMatrices 메서드(gdiplusimageattributes.h)

ImageAttributes::ClearColorMatrices 메서드는 지정된 범주에 대한 색 조정 행렬과 회색조 조정 행렬을 지웁니다.

구문

Status ClearColorMatrices(
  [in, optional] ColorAdjustType type
);

매개 변수

[in, optional] type

형식: ColorAdjustType

조정 행렬이 지워지는 범주를 지정하는 ColorAdjustType 열거형의 요소입니다. 기본값은 ColorAdjustTypeDefault입니다.

반환 값

형식: 상태

메서드가 성공하면 Status 열거형의 요소인 확인을 반환합니다.

메서드가 실패하면 Status 열거형의 다른 요소 중 하나를 반환합니다.

설명

ImageAttributes 개체는 기본, 비트맵, 브러시, 펜 및 텍스트의 다섯 가지 조정 범주에 대한 색 및 회색조 설정을 유지합니다. 예를 들어 기본 범주에 대해 조정 행렬의 쌍(색 및 회색조)을 지정하고 비트맵 범주에 대해 다른 조정 행렬 쌍을 지정하고 펜 범주에 대해 다른 조정 행렬 쌍을 지정할 수 있습니다.

기본 색 및 회색조 조정 설정은 자체 조정 설정이 없는 모든 범주에 적용됩니다. 예를 들어 펜 범주에 대한 조정 설정을 지정하지 않으면 기본 설정이 펜 범주에 적용됩니다.

특정 범주에 대한 색 또는 회색조 조정 설정을 지정하는 즉시 기본 조정 설정이 해당 범주에 더 이상 적용되지 않습니다. 예를 들어 조정 행렬의 쌍(색 및 회색조)과 기본 범주에 감마 값을 지정한다고 가정합니다. ImageAttributes::SetColorMatrices를 호출하여 펜 범주에 대한 조정 행렬 쌍을 설정하는 경우 기본 조정 행렬은 펜에 적용되지 않습니다. 나중에 ImageAttributes::ClearColorMatrices를 호출하여 펜 조정 매트릭스를 지우면 펜 범주가 기본 조정 행렬에 되돌리기 않습니다. 대신 펜 범주에는 조정 행렬이 없습니다. 마찬가지로 펜 범주는 기본 감마 값으로 되돌리기 않습니다. 대신 펜 범주에는 감마 값이 없습니다.

예제

다음 예제에서는 .emf 파일에서 Image 개체를 만듭니다. 또한 이 코드는 ImageAttributes 개체를 만듭니다. ImageAttributes::SetColorMatrices에 대한 첫 번째 호출은 ImageAttributes 개체의 기본 색 조정 행렬과 기본 회색조 조정 행렬을 설정합니다. ImageAttributes::SetColorMatrices에 대한 두 번째 호출은 ImageAttributes 개체의 펜 색 조정 매트릭스와 펜 회색조 조정 매트릭스를 설정합니다. 네 행렬은 다음과 같이 수행됩니다.

  • 기본 색: 빨간색 구성 요소를 1.5로 곱합니다.
  • 기본 회색조: 녹색 구성 요소를 1.5로 곱합니다.
  • 펜 색: 파란색 구성 요소를 1.5로 곱합니다.
  • 펜 회색조: 빨간색, 녹색 및 파란색 구성 요소를 1.5로 곱합니다.

코드는 DrawImage 를 한 번 호출하여 색 조정 없이 이미지를 그립니다. 그런 다음, 코드는 Image 개체의 주소와 ImageAttributes 개체의 주소를 전달할 때마다 DrawImage를 세 번 더 호출합니다. 이미지를 두 번째로 그릴 때(기본 행렬을 설정하는 호출 후) 모든 색은 빨간색 구성 요소가 50% 증가하고 모든 회색은 녹색 구성 요소가 50% 증가합니다. 세 번째로 이미지를 그릴 때(펜 행렬을 설정하는 호출 후) 펜으로 그린 모든 색은 파란색 구성 요소가 50% 증가하고 펜으로 그린 모든 회색은 빨간색, 녹색 및 파란색 구성 요소가 50% 증가합니다. 이미지를 네 번째로 그릴 때( ImageAttributes::ClearColorMatrices를 호출한 후) 펜으로 그린 색과 회색에 조정이 적용되지 않습니다.


VOID Example_SetClearColorMatrices(HDC hdc)
{
   Graphics graphics(hdc);

   Image            image(L"TestMetafile6.emf");
   ImageAttributes  imAtt;
   RectF            rect;
   Unit             unit;

   image.GetBounds(&rect, &unit);

   ColorMatrix defaultColorMatrix = {  // Multiply red component by 1.5.
      1.5f,  0.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  1.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  1.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  1.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  0.0f,  1.0f};

   ColorMatrix defaultGrayMatrix = {  // Multiply green component by 1.5.
      1.0f,  0.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  1.5f,  0.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  1.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  1.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  0.0f,  1.0f};

   ColorMatrix penColorMatrix = {     // Multiply blue component by 1.5.
      1.0f,  0.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  1.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  1.5f,  0.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  1.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  0.0f,  1.0f};

   ColorMatrix penGrayMatrix = {      // Multiply all components by 1.5.
      1.5f,  0.0f,  0.0f,  0.0f,  0.0f,
      0.0f,  1.5f,  0.0f,  0.0f,  0.0f,
      0.0f,  0.0f,  1.5f,  0.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  1.0f,  0.0f,
      0.0f,  0.0f,  0.0f,  0.0f,  1.0f};

   // Set the default color- and grayscale-adjustment matrices.
   imAtt.SetColorMatrices(
      &defaultColorMatrix,
      &defaultGrayMatrix, 
      ColorMatrixFlagsAltGray,
      ColorAdjustTypeDefault); 

   graphics.DrawImage(&image, 10.0f, 10.0f, rect.Width, rect.Height);

   graphics.DrawImage(
      &image, 
      RectF(10.0f, 50.0f, rect.Width, rect.Height),  // destination rectangle 
      rect.X, rect.Y,                // upper-left corner of source rectangle 
      rect.Width,                    // width of source rectangle
      rect.Height,                   // height of source rectangle
      UnitPixel,
      &imAtt);

   // Set the pen color- and grayscale-adjustment matrices.
   imAtt.SetColorMatrices(
      &penColorMatrix,
      &penGrayMatrix, 
      ColorMatrixFlagsAltGray,
      ColorAdjustTypePen); 

   graphics.DrawImage(
      &image, 
      RectF(10.0f, 90.0f, rect.Width, rect.Height),  // destination rectangle 
      rect.X, rect.Y,                // upper-left corner of source rectangle 
      rect.Width,                    // width of source rectangle
      rect.Height,                   // height of source rectangle
      UnitPixel,
      &imAtt);

   imAtt.ClearColorMatrices(ColorAdjustTypePen);

   graphics.DrawImage(
      &image, 
      RectF(10.0f, 130.0f, rect.Width, rect.Height),  // destination rectangle 
      rect.X, rect.Y,                // upper-left corner of source rectangle 
      rect.Width,                    // width of source rectangle
      rect.Height,                   // height of source rectangle
      UnitPixel,
      &imAtt); 
}
				

다음 그림에서는 이전 코드의 출력을 보여 줍니다.

각각 4개의 줄임표를 보여 주는 일러스트레이션; 펜으로 그린 색은 채워진 것보다 색이 다양합니다.

요구 사항

   
지원되는 최소 클라이언트 Windows XP, Windows 2000 Professional [데스크톱 앱만 해당]
지원되는 최소 서버 Windows 2000 Server[데스크톱 앱만]
대상 플랫폼 Windows
헤더 gdiplusimageattributes.h(Gdiplus.h 포함)
라이브러리 Gdiplus.lib
DLL Gdiplus.dll

참고 항목

Bitmap

색상

ColorAdjustType

ColorMatrix

이미지

ImageAttributes

ImageAttributes::ClearColorMatrix

ImageAttributes::SetColorMatrices

ImageAttributes::SetColorMatrix

ImageAttributes::SetToIdentity

Metafile

다시 칠하기