How to effectively crop and scale image data

前端 未结 1 532
既然无缘
既然无缘 2021-01-16 07:12

I need to operate on pixel values in images. Therefore I wrote such a class:

public class image_class
{
    #region property
    public int width { get; priv         


        
相关标签:
1条回答
  • 2021-01-16 07:40

    You don't need all this. In order to copy a rectangular part from a source bitmap, and subsequently scale it, you might simply use a CroppedBitmap and a TransformedBitmap:

    BitmapSource original = ...
    var crop = new CroppedBitmap(original, new Int32Rect(5, 5, 50, 50));
    var result = new TransformedBitmap(crop, new ScaleTransform(0.4, 0.4));
    
    0 讨论(0)
提交回复
热议问题