2012-06-19 4 views
2

Windows Phone 7.5 용 Silverlight를 사용하여 이미지를 여러 개의 작은 이미지로 분할하고 싶습니다.이미지를 여러 조각으로 나누기 silverlight windows phone

우선, 나는 이것이 가능한지 알고 싶습니다. (최근에 Windows phone API로 불쾌한 놀라움을 겪었습니다.) 만약 그렇다면 정확히 아무 것도 찾을 수 없었기 때문에 몇 가지 예를 들어주세요.

도움 주셔서 감사합니다.

답변

4

WriteableBitmapEx는 윈도우 폰과 호환 할 수와 정확히 할 수있는 Crop 방법을 가지고 있습니다. 너비/높이와 X/Y 좌표가 자르는 방법을 알아 내려면 수학을 수행하면됩니다.

//this creates the four quadrants of sourceBitmap as new bitmaps 

int halfWidth = sourceBitmap.PixelWidth/2; 
int halfHeight = sourceBitmap.PixelHeight/2; 

WriteableBitmap topLeft = sourceBitmap.Crop(0, 0, halfWidth, halfHeight); 
WriteableBitmap topRight = sourceBitmap.Crop(halfWidth, 0, halfWidth, halfHeight); 
WriteableBitmap bottomLeft = sourceBitmap.Crop(0, halfHeight, halfWidth, halfHeight); 
WriteableBitmap bottomRight = sourceBitmap.Crop(halfWidth, halfHeight, halfWidth, halfHeight); 

필자는 위의 예에서 픽셀로 인해 테스트하지 않았지만 API를 보여야합니다.

0

실버 라이트 프로젝트를 XNA와 결합하고 spritebatch.Draw()를 사용할 수 있습니다. 원본 사각형에 대한 매개 변수가있어서 이미지에서 부분을 그릴 수 있습니다.

MSDN에는 Silverlight와 XNA를 결합하는 방법에 대한 도움이 있습니다. http://msdn.microsoft.com/en-us/library/hh202938(v=vs.92).aspx

0

올바른 섹션을 렌더링하려면 ScaleTransform과 TranslateTransform을 결합하십시오.

ScaleTransform (numXTiles, numYTiles)

(xTileIndex/numXTiles, yTileIndex/numYTiles) 번역;

장소 그리드 내부의 ImageControl는 클리핑

관련 문제