The following code fragment uses the following code, so extract it and put it in front, so as not to repeat
MemoryStream ms = new MemoryStream (BMPIMGBUF); Bmpimgbuf BMP image buffer contains BMP headers and image data (images can come from files, networks, or devices, etc.)
1. Do not do the conversion, direct display
Bitmapframe BMF = bitmapframe.create (MS, Bitmapcreateoptions.none, Bitmapcacheoption.default);
This.imgViewer.Source = BMF; Imgviewer to Image control
2. Telescopic transform, then show
Mode 1).
var Imgdecoder = bitmapdecoder.create (MS, Bitmapcreateoptions.preservepixelformat, Bitmapcacheoption.none);
var img = imgdecoder.frames[0];
var target = new Transformedbitmap (IMG,
New ScaleTransform (
-640/img. Width * 96/img. Dpix,///If the width is less than the original image width, the width direction is reduced and conversely the magnification is negative, then the flip transform is superimposed
360/img. Height * 96/img. Dpiy,//ditto
0, 0));
This.imgViewer.Source = target;
Mode 2).
Transformedbitmap TBM = new Transformedbitmap ();
Tbm. BeginInit ();
Tbm. Source = Bitmapframe.create (MS, Bitmapcreateoptions.none, Bitmapcacheoption.default);
ScaleTransform st = new ScaleTransform ();
St. ScaleX =-1; Mirrow image on vertical direction
Tbm. Transform = st;
Tbm. EndInit ();
This.imgViewer.Source = TBM;