简体   繁体   中英

How to divide Image into 5*5 pieces Windows phone?

I am developing an application where i have to divide an image into separate images, i have tried with WriteableBitmap , here is my code. Is there any better way to achieve the same?

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>

Code Behind:

How can i divide the image into 5*5 pieces of equal size

    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);

You may try to check the DeepZoom

The Deep Zoom (Seadragon) functionality has been available on Silverlight since version 2. It's a techonology that provides the ability to interactively view high-resolution images. The images need to be prepared using available tools like Deep Zoom Composer and others . The functionality is provided via the usage of the MultiScaleImage control which is availabe on WP7. This control is not there by default in your Toolbox in Visual Studio, however you can just right-click on the Toolbox, select "Choose item..." menu and pick the control from the list

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM