如何在旋转后创建新的位图

时间:2014-11-03 08:54:08

标签: c# winrt-xaml

我已将图像从横向旋转到纵向。

我的问题是,当我使用此代码时图像非常模糊。

我需要做什么?

// create new photo size:
if (b_IsRotated)
{
    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream);
    encoder.SetPixelData(
        BitmapPixelFormat.Bgra8,
        BitmapAlphaMode.Ignore,
        525,
        700,
        DisplayInformation.GetForCurrentView().LogicalDpi,
        DisplayInformation.GetForCurrentView().LogicalDpi,
        pixelBuffer.ToArray());

    await encoder.FlushAsync();
}

_bitmap = new BitmapImage();
_bitmap.SetSource(fileStream);

1 个答案:

答案 0 :(得分:0)

模糊可能与更改位图的大小而不是旋转有关。

您可以通过设置BitmapEncoder的BitmapTransform property来控制位图像素的插值方式。这将允许同时设置RotationInterpolationMode。默认情况下,BitmapEncoder会选择InterpolationMode来强调性能而不是质量,但如果你需要的是质量而不是性能,你可以选择不同的。