2

Windows Phone 8.0 アプリケーションで C# を使用して品質を落とさずに画像のサイズを変更し、画像全体を表示する方法

私がしたこと、

私のXAMLコード:

<StackPanel Orientation="Vertical">
    <TextBlock Text="Select Image" FontSize="45" Height="106"></TextBlock>
    <Image Name="ImgPrev" Height="455" Stretch="None" ></Image>
</StackPanel>

私のC#コード

public MainPage()
{

    InitializeComponent();

    // Sample code to localize the ApplicationBar
    //BuildLocalizedApplicationBar();

    BitmapImage image = new BitmapImage();
    image.SetSource(Application.GetResourceStream(new Uri(@"Assets/Bug.jpg", UriKind.Relative)).Stream);
    image.DecodePixelType = DecodePixelType.Logical;
    image.CreateOptions = BitmapCreateOptions.BackgroundCreation;
    image.CreateOptions = BitmapCreateOptions.DelayCreation;
    Image img = new Image();
    img.Source = image;
    WriteableBitmap wb = new WriteableBitmap(image);
    wb.Resize(1000, 1000, WriteableBitmapExtensions.Interpolation.Bilinear);
    using(MemoryStream stream=new MemoryStream())
    {
        wb.SaveJpeg(stream, 1000, 1000, 0, 100);
        BitmapImage resize = new BitmapImage();
        resize.SetSource(stream);
        ImgPrev.Source = resize;
    }

}

元の画像画像の実際のサイズは 38 MB、寸法 10240x6400、高さ:10240、幅:6400

私が得ている結果は以下の画像です

ここに画像の説明を入力

4

0 に答える 0