Exemple #1
0
        public GrayScaleDialog()
        {
            InitializeComponent();
            _GrayscaleCommand = new GrayscaleCommand();

            //Set command default values
            InitializeUI();
        }
Exemple #2
0
        private void ResetGrayscale(RasterImage image, bool reduce)
        {
            if (image.BitsPerPixel < 24 &&
                (image.Signed || reduce))
            {
                GrayscaleCommand cmgGray;

                cmgGray = new GrayscaleCommand(8);

                cmgGray.Run(image);
            }
        }
Exemple #3
0
        static int Main(string[] args)
        {
            ArgumentAdapter argumentAdapter = new ArgumentAdapter(args);
            ArgumentPayload ap = argumentAdapter.Parse();

            if (ap == null)
            {
                ApplicationUsage();
                return(1);
            }

            Command command;

            switch (ap.ProcessingCommand)
            {
            case Processing.Negative:
                command = new NegativeCommand(ap.BitmapPath, ap.OutcomeBitmapPath);
                break;

            case Processing.Grayscale:
                command = new GrayscaleCommand(ap.BitmapPath, ap.OutcomeBitmapPath);
                break;

            case Processing.Sepia:
                command = new SepiaCommand(ap.BitmapPath, ap.OutcomeBitmapPath);
                break;

            case Processing.Encode:
                command = new TextCodingCommand(ap.BitmapPath, ap.OutcomeBitmapPath, ap.TextToEncoding);
                break;

            case Processing.Decode:
                command = new TextDecodingCommand(ap.BitmapPath);
                break;

            case Processing.Bluish:
                command = new BluishCommand(ap.BitmapPath, ap.OutcomeBitmapPath);
                break;

            default:
                LoggerFacade.Warn("Niepoprawna akcja!");
                return(2);
            }
            command.Execute();
            LoggerFacade.Success("Gotowe!");
            return(0);
        }
Exemple #4
0
        private void GrayScaleDialog_Load(object sender, System.EventArgs e)
        {
            if (_firstTimer)
            {
                _firstTimer = false;
                GrayscaleCommand command = new GrayscaleCommand();
                _initialBitsPerPixel = command.BitsPerPixel;
            }

            BitsPerPixel = _initialBitsPerPixel;

            if (BitsPerPixel == 8)
            {
                _rb8.Checked = true;
            }
            else if (BitsPerPixel == 12)
            {
                _rb12.Checked = true;
            }
            else if (BitsPerPixel == 16)
            {
                _rb16.Checked = true;
            }
        }
Exemple #5
0
        ///----------------------------------------------------------------
        /// <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;
            }
        }
Exemple #6
0
        /// <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;
        }
Exemple #7
0
        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();
        }