Graphics 개체의 보간 모드는 Windows GDI+가 이미지를 스케일링(확장 및 축소)하는 방식에 영향을 줍니다. Gdiplusenums.h의 InterpolationMode 열거형은 다음 목록에 표시된 몇 가지 보간 모드를 정의합니다.
- 최근접 이웃 보간 모드
- InterpolationModeBilinear
- 보간모드고품질이중선형
- 바이큐빅 보간 모드 (InterpolationModeBicubic)
- InterpolationMode 고품질 큐빅 보간법
이미지를 확장하려면 원본 이미지의 각 픽셀을 더 큰 이미지의 픽셀 그룹에 매핑해야 합니다. 이미지를 축소하려면 원래 이미지의 픽셀 그룹을 작은 이미지의 단일 픽셀에 매핑해야 합니다. 이러한 매핑을 수행하는 알고리즘의 효과는 크기 조정된 이미지의 품질을 결정합니다. 더 높은 품질의 크기 조정된 이미지를 생성하는 알고리즘은 처리 시간이 더 많이 필요한 경향이 있습니다. 앞의 목록에서 InterpolationModeNearestNeighbor는 가장 낮은 품질 모드이고 InterpolationModeHighQualityBicubic은 최고 품질 모드입니다.
보간 모드를 설정하려면 InterpolationMode 열거형의 멤버 중 하나를 Graphics 개체의 SetInterpolationMode 메서드에 전달합니다.
다음 예제에서는 이미지를 그린 다음 세 가지 보간 모드로 이미지를 축소합니다.
Image image(L"GrapeBunch.bmp");
UINT width = image.GetWidth();
UINT height = image.GetHeight();
// Draw the image with no shrinking or stretching.
graphics.DrawImage(
&image,
Rect(10, 10, width, height), // destination rectangle
0, 0, // upper-left corner of source rectangle
width, // width of source rectangle
height, // height of source rectangle
UnitPixel);
// Shrink the image using low-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);
graphics.DrawImage(
&image,
Rect(10, 250, 0.6*width, 0.6*height), // destination rectangle
0, 0, // upper-left corner of source rectangle
width, // width of source rectangle
height, // height of source rectangle
UnitPixel);
// Shrink the image using medium-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeHighQualityBilinear);
graphics.DrawImage(
&image,
Rect(150, 250, 0.6 * width, 0.6 * height), // destination rectangle
0, 0, // upper-left corner of source rectangle
width, // width of source rectangle
height, // height of source rectangle
UnitPixel);
// Shrink the image using high-quality interpolation.
graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
graphics.DrawImage(
&image,
Rect(290, 250, 0.6 * width, 0.6 * height), // destination rectangle
0, 0, // upper-left corner of source rectangle
width, // width of source rectangle
height, // height of source rectangle
UnitPixel);
다음 그림에서는 원본 이미지와 세 개의 작은 이미지를 보여 줍니다.
큰 원본 이미지와 다양한 품질의 세 개의 작은 이미지를 보여 주는 