private void ResetGrayscale(RasterImage image, bool reduce) { if (image.BitsPerPixel < 24 && (image.Signed || reduce)) { GrayscaleCommand cmgGray; cmgGray = new GrayscaleCommand(8); cmgGray.Run(image); } }
///---------------------------------------------------------------- /// <summary> /// 伝票画像表示 </summary> /// <param name="iX"> /// 現在の伝票</param> /// <param name="tempImgName"> /// 画像名</param> ///---------------------------------------------------------------- public void ShowImage(string tempImgName) { //string wrkFileName; //修正画面へ組み入れた画像フォームの表示 //画像の出力が無い場合は、画像表示をしない。 if (tempImgName == string.Empty) { leadImg.Visible = false; //global.pblImageFile = string.Empty; return; } //画像ファイルがあるときのみ表示 //wrkFileName = tempImgName; if (System.IO.File.Exists(tempImgName)) { leadImg.Visible = true; //画像ロード RasterCodecs.Startup(); RasterCodecs cs = new RasterCodecs(); // 描画時に使用される速度、品質、およびスタイルを制御します。 RasterPaintProperties prop = new RasterPaintProperties(); prop = RasterPaintProperties.Default; prop.PaintDisplayMode = RasterPaintDisplayModeFlags.Resample; leadImg.PaintProperties = prop; leadImg.Image = cs.Load(tempImgName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); //画像表示倍率設定 if (gl.miMdlZoomRate == 0f) { if (leadImg.ImageDpiX == 200) { leadImg.ScaleFactor *= gl.ZOOM_RATE; // 200*200 画像のとき } else { leadImg.ScaleFactor *= gl.ZOOM_RATE; // 300*300 画像のとき } } else { leadImg.ScaleFactor *= gl.miMdlZoomRate; } //画像のマウスによる移動を可能とする leadImg.InteractiveMode = RasterViewerInteractiveMode.Pan; ////右へ90°回転させる //RotateCommand rc = new RotateCommand(); //rc.Angle = 90 * 100; //rc.FillColor = new RasterColor(255, 255, 255); ////rc.Flags = RotateCommandFlags.Bicubic; //rc.Flags = RotateCommandFlags.Resize; //rc.Run(leadImg.Image); // グレースケールに変換 GrayscaleCommand grayScaleCommand = new GrayscaleCommand(); grayScaleCommand.BitsPerPixel = 8; grayScaleCommand.Run(leadImg.Image); leadImg.Refresh(); cs.Dispose(); RasterCodecs.Shutdown(); //global.pblImageFile = wrkFileName; // 画像操作ボタン btnPlus.Enabled = true; btnMinus.Enabled = true; } else { //画像ファイルがないとき leadImg.Visible = false; //global.pblImageFile = string.Empty; // 画像操作ボタン btnPlus.Enabled = false; btnMinus.Enabled = false; } }
/// <summary> /// Batch 2 Functions /// </summary> private void DoBatch2() { // save the current caption string tmpCaption = Text; // disable the form Enabled = false; // change cursor Cursor = Cursors.SizeNS; // Do AntiAlias Text = "AntiAliasing Image..."; AntiAliasingCommand antiAliasingCommand = new AntiAliasingCommand(); antiAliasingCommand.Threshold = 25; antiAliasingCommand.Dimension = 7; antiAliasingCommand.Filter = AntiAliasingCommandType.Type1; antiAliasingCommand.Run(_viewer.Image); Text = "Image Is AntiAliased"; _viewer.Refresh(); Thread.Sleep(2000); // change cursor Cursor = Cursors.SizeWE; // Do Reverse Text = "Reversing Image..."; FlipCommand flipCommand = new FlipCommand(); flipCommand.Horizontal = true; flipCommand.Run(_viewer.Image); Text = "Image Is Reversed"; _viewer.Refresh(); Thread.Sleep(2000); // change cursor Cursor = Cursors.SizeNS; // Do Grayscale Text = "Grayscaling Image..."; GrayscaleCommand grayScaleCommand = new GrayscaleCommand(); grayScaleCommand.BitsPerPixel = 8; grayScaleCommand.Run(_viewer.Image); Text = "Image Is Grayscaled"; _viewer.Refresh(); Thread.Sleep(2000); // change cursor Cursor = Cursors.SizeWE; // Do Invert Text = "Inverting Image..."; InvertCommand invertCommand = new InvertCommand(); invertCommand.Run(_viewer.Image); Text = "Image Is Inverted, Batch Is Complete"; _viewer.Refresh(); Thread.Sleep(2000); // change the cursor to arrow Cursor = Cursors.Arrow; // enable the form Enabled = true; // return the old caption Text = tmpCaption; }
private void _btnOK_Click(object sender, EventArgs e) { if (radioResize.Checked) { if (_txtWidth.Value < 32) { if (_width > 32) { MessageBox.Show("Width is too small, Must be at least 32"); return; } } if (_txtHeight.Value < 32) { if (_height > 32) { MessageBox.Show("Height is too small, Must be at least 32"); return; } } int i; SizeCommand sizeCommand = new SizeCommand(_txtWidth.Value, _txtHeight.Value, RasterSizeFlags.Resample); GrayscaleCommand grayCommand = new GrayscaleCommand(8); int oldWidth = _image.Width; int oldHeight = _image.Height; for (i = 1; i <= _image.PageCount; i++) { _image.Page = i; grayCommand.Run(_image); sizeCommand.Run(_image); } _object.VoxelSpacing = new Medical3DPoint(_object.VoxelSpacing.X * oldWidth / _txtWidth.Value, _object.VoxelSpacing.Y * oldHeight / _txtHeight.Value, _object.VoxelSpacing.Z); } else { if (Math.Abs(_txtCropWidthTo.Value - _txtCropWidthFrom.Value) < 32) { if (_width > 32) { MessageBox.Show("Width is too small, Must be at least 32"); return; } } if (_txtHeight.Value < 32) { if (_height > 32) { MessageBox.Show("Height is too small, Must be at least 32"); return; } } if (Math.Abs(_txtCropHeightTo.Value - _txtCropHeightFrom.Value) < 32) { MessageBox.Show("Height is too small, Must be at least 32"); return; } int i; CropCommand cropCommand = new CropCommand(new Rectangle(_txtCropWidthFrom.Value, _txtCropHeightFrom.Value, _txtCropWidthTo.Value - _txtCropWidthFrom.Value, _txtCropHeightTo.Value - _txtCropHeightFrom.Value)); GrayscaleCommand grayCommand = new GrayscaleCommand(8); for (i = 1; i <= _image.PageCount; i++) { _image.Page = i; grayCommand.Run(_image); cropCommand.Run(_image); } _object.FirstPosition = new Medical3DPoint(_object.FirstPosition.X + _object.ImageOrientation[0] * _txtCropWidthFrom.Value + _object.ImageOrientation[3] * _txtCropHeightFrom.Value, _object.FirstPosition.Y + _object.ImageOrientation[1] * _txtCropWidthFrom.Value + _object.ImageOrientation[4] * _txtCropHeightFrom.Value, _object.FirstPosition.Z + _object.ImageOrientation[2] * _txtCropWidthFrom.Value + _object.ImageOrientation[5] * _txtCropHeightFrom.Value); _object.SecondPosition = new Medical3DPoint(_object.SecondPosition.X + _object.ImageOrientation[0] * _txtCropWidthFrom.Value + _object.ImageOrientation[3] * _txtCropHeightFrom.Value, _object.SecondPosition.Y + _object.ImageOrientation[1] * _txtCropWidthFrom.Value + _object.ImageOrientation[4] * _txtCropHeightFrom.Value, _object.SecondPosition.Z + _object.ImageOrientation[2] * _txtCropWidthFrom.Value + _object.ImageOrientation[5] * _txtCropHeightFrom.Value); } this.DialogResult = DialogResult.OK; this.Close(); }