.NET에서 초대형 이미지를 볼 때 탐색하기

블로그 카테고리: 이미징.NET

2020/05/13

이 문서에서는 VintaSoft Imaging .NET SDKImageMapTool 클래스를 사용하여 대형 및 초대형 이미지를 보는 방법을 설명합니다.

예시로 4067 메가픽셀(35878x113378 픽셀) 크기의 JPEG2000 이미지를 사용해 보겠습니다.
다음은 VintaSoft Imaging Demo에서 JPEG2000 이미지를 1% 확대한 스크린샷:


VintaSoft Imaging Demo에서 JPEG2000 이미지를 10% 확대한 스크린샷:


매우 큰 이미지를 볼 때, 현재 이미지의 어느 부분에 있는지, 원하는 위치로 이동하려면 어디로 가야 하는지 파악하기 어려운 경우가 많습니다. 일반적으로 이러한 불편함은 이미지를 축소한 다음 원하는 영역을 확대하는 방식으로 해결할 수 있습니다. 하지만 이미지 디코딩에 상당한 리소스가 소모되는 경우, 이 방법은 허용할 수 없을 정도로 오랜 시간이 걸릴 수 있습니다. ImageMapTool 클래스를 사용하는 이미지 맵은 이러한 문제를 해결하는 편리하고 효율적인 방법입니다.

VintaSoft Imaging Demo에서는 "보기 -> 이미지 맵 설정..." 메뉴 항목을 사용하여 이미지 맵을 활성화할 수 있습니다. 아래 스크린샷은 VintaSoft Imaging Demo의 이미지 맵 설정을 보여줍니다.



이미지 맵은 메인 이미지 뷰어 위에 위치한 작은 이미지 뷰어로, 동일한 이미지를 다른 배율로 보여줍니다. 아래 스크린샷은 메인 이미지 뷰어의 현재 확대/축소 배율을 기준으로 1/25 배율로 설정된 이미지 맵을 보여줍니다.



ImageMapTool 클래스:

ImageViewer.ViewerBufferSize 속성을 사용하면 이미지 뷰어에서 보이는 영역(노란색 사각형) 주변의 완전히 캐시된 사각형의 크기를 메가픽셀 단위로 지정할 수 있습니다. 아래 스크린샷은 이미지 뷰어에서 보이는 영역 주변의 캐시된 영역 크기를 6메가픽셀로 설정한 이미지 뷰어의 모습입니다.




또한, 매우 매우 큰 이미지의 경우 이미지 뷰어에서 여러 개의 ImageMapTool 요소를 동시에 사용할 수 있으며, 각 요소는 서로 다른 상대적 배율을 ​​가질 수 있습니다.이는 여러 시각화 도구의 기능을 결합할 수 있도록 해주는 CompositeVisualTool 클래스 덕분에 가능합니다.
다음은 이미지 뷰어에 두 개의 이미지 맵을 생성하는 C# 코드입니다.
// create the first image map tool
Vintasoft.Imaging.UI.VisualTools.ImageMapTool imageMap1 = new Vintasoft.Imaging.UI.VisualTools.ImageMapTool();
// specify that image map must be enabled
imageMap1.Enabled = true;
// specify that image map tool must show image in best fit mode
imageMap1.Zoom = 0;
// specify that image map must have size 200x200 pixels
imageMap1.Size = new System.Drawing.Size(200, 200);
// specify that image map must be shown at the left-top corner of image viewer
imageMap1.Anchor = Vintasoft.Imaging.UI.AnchorType.Left | Vintasoft.Imaging.UI.AnchorType.Top;
// specify that image map tool border must have red color
imageMap1.CanvasPen = new System.Drawing.Pen(System.Drawing.Color.Red);
// specify that the border of image's visible region in image map must have lime color
imageMap1.VisibleRectPen = new System.Drawing.Pen(System.Drawing.Color.Lime);

// create the second image map tool
Vintasoft.Imaging.UI.VisualTools.ImageMapTool imageMap2 = new Vintasoft.Imaging.UI.VisualTools.ImageMapTool();
// specify that image map must be enabled
imageMap2.Enabled = true;
// specify that image map tool must show image in 1/25 scale from image viewer zoom
imageMap2.Zoom = 1 / 25f;
// specify that image map must have size 200x200 pixels
imageMap1.Size = new System.Drawing.Size(200, 200);
// specify that image map must be shown at the left-bottom corner of image viewer
imageMap2.Anchor = Vintasoft.Imaging.UI.AnchorType.Left | Vintasoft.Imaging.UI.AnchorType.Bottom;
// specify that image map tool border must have red color
imageMap2.CanvasPen = new System.Drawing.Pen(System.Drawing.Color.Red);
// specify that the border of image's visible region in image map must have lime color
imageMap2.VisibleRectPen = new System.Drawing.Pen(System.Drawing.Color.Lime);

// create composite visual tool that combines first and second image map tools
Vintasoft.Imaging.UI.VisualTools.CompositeVisualTool compositeVisualTool = new Vintasoft.Imaging.UI.VisualTools.CompositeVisualTool(imageMap1, imageMap2);

// set composite visual tool as current visual tool of image viewer
imageViewer1.VisualTool = compositeVisualTool;

아래 스크린샷은 두 개의 이미지 맵이 표시된 이미지 뷰어를 보여줍니다.