[英]How to divide Image into 5*5 pieces Windows phone?
我正在開發一個應用程序,其中我必須將圖像分成單獨的圖像,我已經嘗試過WriteableBitmap,這是我的代碼。 有沒有更好的方法可以達到相同目的?
XAML
<Grid Name="gridCollague" HorizontalAlignment="Left" Height="473" Margin="10,0,0,0" VerticalAlignment="Top" Width="446">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
</Grid>
背后的代碼:
我如何將圖像分成5 * 5大小相等的片段
int halfWidth = wb.PixelWidth / 5;
int halfHeight = wb.PixelHeight / 5;
WriteableBitmap img1 = wb.Crop(0, 0, halfWidth, halfHeight);
WriteableBitmap img2 = wb.Crop(halfWidth, 0, halfWidth, halfHeight);
WriteableBitmap img3 = wb.Crop(0, halfHeight, halfWidth, halfHeight);
WriteableBitmap img4 = wb.Crop(halfWidth, halfHeight, halfWidth, halfHeight);
您可以嘗試檢查DeepZoom
從版本2開始, Deep Zoom(Seadragon)功能已在Silverlight上提供。該技術提供了交互式查看高分辨率圖像的功能。 需要使用可用的工具(如Deep Zoom Composer等)來准備圖像。 該功能是通過使用WP7上提供的MultiScaleImage控件提供的。 默認情況下,Visual Studio中的“工具箱”中沒有此控件,但是您可以右鍵單擊“工具箱”,選擇“選擇項目...”菜單,然后從列表中選擇該控件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.