How to resize an Image C#

前端 未结 17 2401
暗喜
暗喜 2020-11-21 22:28

As Size, Width and Height are Get() properties of System.Drawing.Image;
How can I resize an Image object

17条回答
  •  醉话见心
    2020-11-21 23:07

    If you're working with a BitmapSource:

    var resizedBitmap = new TransformedBitmap(
        bitmapSource,
        new ScaleTransform(scaleX, scaleY));
    

    If you want finer control over quality, run this first:

    RenderOptions.SetBitmapScalingMode(
        bitmapSource,
        BitmapScalingMode.HighQuality);
    

    (Default is BitmapScalingMode.Linear which is equivalent to BitmapScalingMode.LowQuality.)

提交回复
热议问题