コード例 #1
0
ファイル: Logic.cs プロジェクト: Desm0nt/AppMag_POZV_DESM0nt
        /// <summary>
        /// Обработка операций со списком ListBox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (radioButton1.Checked)
            {
                _formShow = new FormShow();
                var drawArea = new Bitmap(_formShow.pictureBox1.Size.Width, _formShow.pictureBox1.Size.Height,
                                          System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                _formShow.pictureBox1.Image = drawArea;

                int    index    = listBox1.IndexFromPoint(e.Location);
                string pathtext = listBox1.GetItemText(listBox1.SelectedItem);
                _currentIndexlayer = index;
                Graphics g;
                g = Graphics.FromImage(drawArea);

                Brush gBrush = Brushes.White;
                Brush wBrush = Brushes.Black;

                for (int w = 0; w < _layers[index].Dicom.width; ++w)
                {
                    for (int h = 0; h < _layers[index].Dicom.height; ++h)
                    {
                        g.FillRectangle(
                            _layers[index].Dicom.Pixels16[w * _layers[index].Dicom.height + h] >= 32900 ? gBrush : wBrush,
                            h, w, 1, 1);
                    }
                }

                _formShow.Text = _layers[index].Dicom.DicomFileName;
                _formShow.pictureBox1.Image = drawArea;
                drawArea.Save(pathtext + ".jpg", ImageFormat.Jpeg);
                g.Dispose();
                _formShow.Show();
            }
            if (radioButton3.Checked)
            {
                if (_currentIndexlayer == listBox1.SelectedIndex)
                {
                    _currentIndexlayer = -1;
                }
                _layers.RemoveAt(listBox1.SelectedIndex);
                UpdateListBox();
            }
        }
コード例 #2
0
ファイル: Logic.cs プロジェクト: Desm0nt/AppMag_POZV_DESM0nt
        private void GenImage(string path, DicomDecoder dicom)
        {
            _formShow = new FormShow();
            var drawArea = new Bitmap(_formShow.pictureBox1.Size.Width, _formShow.pictureBox1.Size.Height,
                                      System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            //_formShow.pictureBox1.Image = drawArea;

            int    index    = 0;
            string pathtext = path;

            _currentIndexlayer = index;
            Graphics g;

            g = Graphics.FromImage(drawArea);

            Brush gBrush = Brushes.White;
            Brush wBrush = Brushes.Black;

            for (int w = 0; w < dicom.width; ++w)
            {
                for (int h = 0; h < dicom.height; ++h)
                {
                    g.FillRectangle(
                        dicom.Pixels16[w * dicom.height + h] >= 32900 ? gBrush : wBrush,
                        h, w, 1, 1);
                }
            }

            int a = 8;

            _formShow.Text = dicom.DicomFileName;
            //_formShow.pictureBox1.Image = drawArea;
            var filepath = Path.GetDirectoryName(pathtext);
            var filename = Path.GetFileNameWithoutExtension(pathtext);
            //Bitmap bitmap = new Bitmap(filepath + "\\jpg\\" + filename + ".jpg");
            var resized = ResizeBitmap(drawArea, drawArea.Width / a, drawArea.Height / a);

            Directory.CreateDirectory(filepath + "\\png\\");
            resized.Save(filepath + "\\png\\" + filename + ".png", ImageFormat.Png);
            g.Dispose();
        }
コード例 #3
0
ファイル: Logic.cs プロジェクト: Desm0nt/AppMag_POZV_DESM0nt
        private void button3_Click(object sender, EventArgs e)
        {
            int i = 0;

            foreach (var a in listBox1.Items)
            {
                _formShow = new FormShow();
                var drawArea = new Bitmap(_formShow.pictureBox1.Size.Width, _formShow.pictureBox1.Size.Height,
                                          System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                //_formShow.pictureBox1.Image = drawArea;

                int    index    = i;
                string pathtext = listBox1.GetItemText(a);
                _currentIndexlayer = index;
                Graphics g;
                g = Graphics.FromImage(drawArea);

                Brush gBrush = Brushes.White;
                Brush wBrush = Brushes.Black;

                for (int w = 0; w < _layers[index].Dicom.width; ++w)
                {
                    for (int h = 0; h < _layers[index].Dicom.height; ++h)
                    {
                        g.FillRectangle(
                            _layers[index].Dicom.Pixels16[w * _layers[index].Dicom.height + h] >= 32900 ? gBrush : wBrush,
                            h, w, 1, 1);
                    }
                }

                _formShow.Text = _layers[index].Dicom.DicomFileName;
                //_formShow.pictureBox1.Image = drawArea;
                var    filepath = Path.GetDirectoryName(pathtext);
                var    filename = Path.GetFileNameWithoutExtension(pathtext);
                Bitmap bitmap   = new Bitmap(filepath + "\\jpg\\" + filename + ".jpg");
                drawArea.Save(filepath + "\\jpg\\" + filename + ".jpg", ImageFormat.Jpeg);
                g.Dispose();
                i++;
            }
        }