Tech/Silverlight2009. 8. 3. 13:06
Deep Zoom 강좌 by ONESTONE


1. 개별 이미지의 위치 정보 얻기


1. 개별 이미지의 위치 정보 얻기

- Deep Zoom Composer를 통해 내보내기 한 결과물에서 Metadata.xml 파일을 보면 다음과 같은 정보를 얻을 수 있다.


AspectRatio : 전체 이미지의 Width / Height 비율
x, y : 이미지의 위치, 1을 기준으로 비율에 맞추어 변경한 값
width, height : 이미지의 크기, 1을 기준으로 비율에 맞추어 변경한 값

하지만 MultiScaleImage 컨트롤은 Metadata.xml 파일을 사용하는 것이 아니라, 추가적으로 내보내기 되는 dzc_output.xml 파일을 사용한다.

- dzc_output.xml 파일에서는 다음과 같은 정보를 얻을 수 있다.

Size : 원본 이미지의 Width, Height
Viewport.Width : 원본 이미지를 얼마만큼 확대/축소 하였는지 나타나는 비율
Viewport.X, Y : Viewport.Width의 비율에 따라서 이미지의 X, Y 위치, 1을 기준으로 비율에 맞추어 변경한 값

- 실제 개별 이미지의 영역 정보를 얻기 위해서는 MultiScaleImage 컨트롤로 부터 얻을 수 있는 MultiScaleSubImage들의 Collection을 이용하면 된다. 이것은 MultiScaleImage의 SubImages를 통해서 얻을 수 있다. 얻은 Collection은 MultiScaleImage의 Collection이고 각각의 MultiScaleImage에서 위에서 얻을 수 있는 Viewport Width, X, Y 정보를 얻을 수 있게 된다.

- SubImage의 Viewport 정보를 이용해서 SubImage의 X, Y, Width, Height는 다음과 같이 계산할 수 있다.

- 위 식을 이용하여 특정 Point가 속해 있는 SubImage를 얻는 코드는 다음과 같다.

<MultiScaleImage x:Name="msi" ... />

Point pt = msi.ElementToLogicalPoint(구하기 원하는 Point)
foreach (MultiScaleSubImage subImage in msi.SubImages)
{
if (pt.X >= -subImage.ViewportOrigin.X / subImage.ViewportWidth &&
    pt.X <= -subImage.ViewportOrigin.X / subImage.ViewportWidth + 1 / subImage.ViewportWidth &&
    pt.Y >= -subImage.ViewportOrigin.Y / subImage.ViewportWidth &&
    pt.Y <= -subImage.ViewportOrigin.Y / subImage.ViewportWidth + 1 / subImage.ViewportWidth / subImage.AspectRatio)
{
// 찾았다!!!
}
}



'Tech > Silverlight' 카테고리의 다른 글

[Behavior 만들기]  (0) 2009.10.01
[MVVM/Command Pattern]  (0) 2009.10.01
Silverlight 3 _ 3D  (0) 2009.06.18
ImageButton 만들기  (0) 2009.06.11
Posted by 알 수 없는 사용자
Tech/Silverlight2009. 6. 18. 19:05
Silverligh 3의 UI Element에 Projection 프라퍼티가 추가되었다. 
이를 이용하면 간단한 3D 효과를 구현할 수 있다.

Image와 Button을 각각 Y축으로 30도 Z축으로 35도 회전하는 것을 다음과 같은 코드로 구현할 수 있다.

<Image x:Name="myImage" Source="[0253].jpg">
<Image.Projection>
<PlaneProjection RotationY="30"/>
</Image.Projection>
</Image>

<Button Content="Button" Click="Button_Click">
<Button.Projection>
<PlaneProjection RotationZ="35" />
</Button.Projection>
</Button>


Projection에서 제공하는 것은 회전 x,y,z 축 회전 외에도 다음과 같은 것들이 있다.
- 회전 중심점 변경 (CenterOf...)
- 회전 축 고정 평행 이동 (GlobalOffset...)
- 회전 축 변경 평형 이동 (LocalOffset...)

'Tech > Silverlight' 카테고리의 다른 글

[MVVM/Command Pattern]  (0) 2009.10.01
Deep Zoom Composer 에서 개별 이미지 요소 정보 얻기  (0) 2009.08.03
ImageButton 만들기  (0) 2009.06.11
Silverlight2 Unit Test  (0) 2009.05.19
Posted by 알 수 없는 사용자