WPF easy bitmap resize

Here is an example of a really easy way to resize a bitmap using WPF imaging classes.

 public static BitmapSource ResizeBitmap(BitmapSource source, int nWidth, int nHeight)
   TransformedBitmap tbBitmap = new TransformedBitmap(source,
                                             new ScaleTransform(nWidth / source.PixelWidth,
                                                                nHeight / source.PixelHeight,
                                                                0, 0));
   return tbBitmap;

Comments (0)

› No comments yet.

Pingbacks (0)

› No pingbacks yet.