public BitmapImage showSingleFrm(UInt16 frm) { this.Row.Content = $"{frm}"; int height = ImageInfo.dtImgInfo.Rows.Count; if (frm < height) { Bitmap bmp = BmpOper.MakeFrameImage(frm, height); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); BitmapImage bmpSource = new BitmapImage(); bmpSource.BeginInit(); bmpSource.StreamSource = ms; bmpSource.EndInit(); ImageSingleFrm.Source = bmpSource; return(bmpSource); } ImageSingleFrm.Source = null; return(null); }
public async void pickSingleImage(UInt16 Z) { UInt16[] band = { Z, Z, Z }; if ((Ctrl_ImageView)((MultiFuncWindow)App.global_Windows[0]).UserControls[0] != null) { ((Ctrl_ImageView)((MultiFuncWindow)App.global_Windows[0]).UserControls[0]).RefreshPseudoColor(0, ImageInfo.strFilesPath, 4, band, ColorRenderMode.Grayscale); } if (Z < 1 || Z > 160) { return; } //Bitmap bmp = await DataProc.GetBmp(ImageInfo.strFilesPath, Z - 1, ColorRenderMode.Grayscale); Bitmap bmp = await BmpOper.MakePseudoColor(ImageInfo.strFilesPath, band, 4, ImageInfo.imgWidth); if (bmp == null) { return; } bmp.RotateFlip(RotateFlipType.Rotate180FlipNone); bmp.RotateFlip(RotateFlipType.Rotate180FlipY); BitmapImage bmpSource = new BitmapImage(); if (!File.Exists($"bmpFiles\\{Z}.bmp")) { bmp.Save($"bmpFiles\\{Z}.bmp"); } bmpSource = new BitmapImage(new Uri($"{Environment.CurrentDirectory}\\bmpFiles\\{Z}.bmp")); gm3d_Active.Material = new DiffuseMaterial(new System.Windows.Media.ImageBrush(bmpSource)); DoubleAnimation day = new DoubleAnimation { From = 0, To = imheight / 10 / (imheight / 600), Duration = new Duration(TimeSpan.FromSeconds(1)) }; //TranslateTransform3D transtrans3d = new TranslateTransform3D(0, 0, scene.touchPoint.Z); TranslateTransform3D transtrans3d = new TranslateTransform3D(0, 0, ((Z - 80) * 0.4)); gm3d_Active.Transform = transtrans3d; transtrans3d.BeginAnimation(TranslateTransform3D.OffsetYProperty, day); curBand.Content = Z.ToString(); }
/// <summary> /// 生成单帧图像并绑定Image控件 /// </summary> /// <param name="frm">帧号</param> public void showSingleFrm(UInt16 frm) { txtSetFrame.Text = frm.ToString(); int height = ImageInfo.dtImgInfo.Rows.Count; frm = Convert.ToUInt16(frm - ImageInfo.startFrm); if (frm < height) { Bitmap bmp = BmpOper.MakeFrameImage(frm, height); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); BitmapImage bmpSource = new BitmapImage(); bmpSource.BeginInit(); bmpSource.StreamSource = ms; bmpSource.EndInit(); ImageSingleFrm.Source = bmpSource; return; } ImageSingleFrm.Source = null; return; }
public async void RefreshPseudoColor(int sub, string path, UInt16 gain, UInt16[] band, ColorRenderMode cMode) { this.Busy.isBusy = true; SubWinIndex = sub; colorBand = band; colorMode = cMode; for (int i = 0; i < 3; i++) { colorWave[i] = (UInt16)ImageInfo.getWave(colorBand[i]); } band[0] -= 1; band[1] -= 1; band[2] -= 1; Bitmap bmp = await BmpOper.MakePseudoColor2(sub, path, band, gain); band[0] += 1; band[1] += 1; band[2] += 1; if (bmp == null) { return; } bmp.RotateFlip(RotateFlipType.Rotate90FlipX); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); ImgW = bmp.Width; ImgH = bmp.Height; BitmapImage bmpSource = new BitmapImage(); bmpSource.BeginInit(); bmpSource.StreamSource = ms; bmpSource.EndInit(); this.IMG1.Source = bmpSource; viewSet(); this.Busy.isBusy = false; }