Ejemplo n.º 1
0
        void PrintImg()
        {
            try
            {
                using (Leadtools.Commands.Demos.WaitCursor wait = new Leadtools.Commands.Demos.WaitCursor())
                {
                    strErrorWhenRealizing = "";
                    NoErrorWhilePreparing4Printing = true;
                    if (!Directory.Exists(PrintTempFolder)) Directory.CreateDirectory(PrintTempFolder);
                    Try2DeletePreviousImages();
                    htbFiles.Clear();

                    int CountOfImg = GetCellCountHasImage();
                    if (CountOfImg <= 0)
                    {
                        new frm_LargeMsgBoxOK("THÔNG BÁO", "Bạn phải chọn ít nhất một ảnh của Bệnh nhân trước khi nhấn nút In. Mời bạn chọn lại...", "TÔI ĐÃ HIỂU", "KHÔNG HIỂU").ShowDialog();
                        return;
                    }
                    htbDetail = new Hashtable();
                    foreach (MedicalViewerCell _cell in _DicomMedicalViewer._medicalViewerPrintDirect.Cells)
                    {
                        int _Row = _cell.Position.Row + 1;
                        int _Col = _cell.Position.Column + 1;
                        string RC = "11";
                        string fileName2Print = PrintTempFolder + @"\" + Path.GetFileName(_cell.Tag.ToString());
                        using (DicomDataSet ds = new DicomDataSet())
                        {
                            ds.Load(_cell.Tag.ToString(), DicomDataSetLoadFlags.LoadAndClose);
                            string ID_Name = GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientID) + " " + GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientName);
                            string Birthday_Sex_Age = "";
                            string BD = GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientBirthDate).Trim();
                            string BT = GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientBirthTime).Trim();
                            string Sex = TranslateSex(GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientSex).Trim());
                            string Age = GetStringValue(ds, Leadtools.Dicom.DicomTag.PatientAge).Trim();
                            string ID_Name_Age_Sex = ID_Name;// +" " + Age;// +" " + Sex;
                            if (BD != "") Birthday_Sex_Age += BD;
                            //if (BT != "") Birthday_Sex_Age += BD;
                            if (Sex != "") Birthday_Sex_Age += " [" + Sex + "] ";
                            if (Age != "") Birthday_Sex_Age += Age + " T";
                            _DicomMedicalViewer.CreateDefaultAnnotationOnImage(_cell, Color.White, Color.Black, HospitalName, DepartmentName, ID_Name_Age_Sex, DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt"));

                            if (!BurnText16(_cell))
                            {
                                strErrorWhenRealizing = "";
                                NoErrorWhilePreparing4Printing = true;
                                RealizeAnnotation(_cell.Image, (MedicalViewerMultiCell)_cell);
                            }
                            if (!NoErrorWhilePreparing4Printing) break;
                            //Lưu ảnh
                            SaveImg(_cell, fileName2Print, ds);

                        }


                        //Save ảnh đã xử lý +Chèn Annotation nếu có
                        if (!htbFiles.Contains(RC)) htbFiles.Add(RC, fileName2Print);
                        if (!htbDetail.Contains(_cell.TabIndex)) htbDetail.Add(_cell.TabIndex, 0);
                    }

                    Thread t1 = new Thread(new ThreadStart(Sent2Print));
                    t1.Start();
                    tryUpdatePrintCount();
                    try2ResetScheduledStatus(htbDetail);
                    DisposeMedicalViewer();
                }
            }
            catch
            {
            }
            finally
            {
                _DicomMedicalViewer.m_blnIsCropping = false;
                NoErrorWhilePreparing4Printing = true;
            }
        }
Ejemplo n.º 2
0
        void test()
        {


            string imgFile = @"C:\Images\Chest.dcm";
            try
            {

                using (Leadtools.Commands.Demos.WaitCursor wait = new Leadtools.Commands.Demos.WaitCursor())
                {

                    DicomDataSet ds = new DicomDataSet();
                    ds.Load(imgFile, DicomDataSetLoadFlags.LoadAndClose);

                    DicomElement pixelDataElement = ds.FindFirstElement(null, DicomTag.PixelData, true);
                    DicomImageInformation imageInformation = ds.GetImageInformation(pixelDataElement, 0);
                    ds.SetImages(pixelDataElement, _CurrCell.Image.CloneAll(), imageInformation.Compression, imageInformation.PhotometricInterpretation,
                                _CurrCell.Image.BitsPerPixel, 2, DicomSetImageFlags.AutoSetVoiLut);
                    ds.Save(imgFile, DicomDataSetSaveFlags.None);
                   }
            }
            catch (Exception ex)
            {
               

            }
           
        }
Ejemplo n.º 3
0
        private void AutoApplyWW_WC(RasterImage img)
        {
            
            try
            {
                if (lblAppliedLastWL.IsChecked==false || WC == 0 || WW == 0)
                {
                    AllowAppliedWL = false;
                    return;
                }
                using (Leadtools.Commands.Demos.WaitCursor wait = new Leadtools.Commands.Demos.WaitCursor())
                {


                    if (img.Order == RasterByteOrder.Gray && img.BitsPerPixel > 8)
                    {
                        // update lookup table

                        try
                        {

                            ApplyLinearVoiLookupTableCommand command = new ApplyLinearVoiLookupTableCommand();
                            MinMaxBitsCommand minMaxBits = new MinMaxBitsCommand();
                            MinMaxValuesCommand minMaxValues = new MinMaxValuesCommand();
                            if (ADJUST_WOB)
                                command.Flags = VoiLookupTableCommandFlags.ReverseOrder;
                            else
                                command.Flags = VoiLookupTableCommandFlags.None;

                            minMaxBits.Run(img);
                            img.LowBit = minMaxBits.MinimumBit;
                            img.HighBit = minMaxBits.MaximumBit;
                            minMaxValues.Run(img);
                            command.Width = WW;
                            command.Center = WC;
                            command.Run(img);
                            //_CurrCell.Invalidate();
                        }
                        catch
                        {
                        }
                    }



                }
            }
            catch
            {
            }
            finally
            {
               
            }
        }
Ejemplo n.º 4
0
        private void Autosave4Toshiba()
        {
            //RasterImage img = null;
            string SaveFile = _CurrCell.Tag.ToString();
            try
            {
                if (!_DicomMedicalViewer.IsValidCell()) return;
                using (Leadtools.Commands.Demos.WaitCursor wait = new Leadtools.Commands.Demos.WaitCursor())
                {
                    AppLogger.LogAction.ShowEventStatus(lblFPDStatus,MultiLanguage.GetText(globalVariables.DisplayLanguage, "Đang lưu ảnh...", "Saving image..."));
                    RasterImageFormat _originalFormat = RasterImageFormat.DicomGray;
                    int _originalBPP = 16;
                    _originalFormat = _CurrCell.Image.OriginalFormat;
                    _originalBPP = _CurrCell.Image.BitsPerPixel;
                    DicomDataSet ds = new DicomDataSet();
                    ds.Load(_CurrCell.Tag.ToString(), DicomDataSetLoadFlags.LoadAndClose);

                    DicomElement pixelDataElement = CurrentDicomDS.FindFirstElement(null, DicomTag.PixelData, true);
                    DicomImageInformation imageInformation = CurrentDicomDS.GetImageInformation(pixelDataElement, 0);
                    using (RasterImage img = _CurrCell.Image.CloneAll().CreateThumbnail(pnlImgViewer.Width, pnlImgViewer.Height, _originalBPP, _CurrCell.Image.ViewPerspective, RasterSizeFlags.Bicubic))
                    {
                        CurrentDicomDS.SetImages(pixelDataElement, img, imageInformation.Compression, imageInformation.PhotometricInterpretation,
                                _originalBPP, 2, DicomSetImageFlags.None);
                        CurrentDicomDS.Save(Application.StartupPath + @"\Toshiba.dcm", DicomDataSetSaveFlags.None);
                    }
                  
                }
            }
            catch (Exception ex)
            {
             

            }
        }
Ejemplo n.º 5
0
        private void AutoApplyWW_WC()
        {
            bool AllowAppliedWL = true;
            try
            {
                if (lblAppliedLastWL.IsChecked==false || WC == 0 || WW == 0)
                {
                    AllowAppliedWL = false;
                    return;
                }
                using (Leadtools.Commands.Demos.WaitCursor wait = new Leadtools.Commands.Demos.WaitCursor())
                {


                    if (_CurrCell.Image.Order == RasterByteOrder.Gray && _CurrCell.Image.BitsPerPixel > 8)
                    {
                        // update lookup table

                        try
                        {

                            ApplyLinearVoiLookupTableCommand command = new ApplyLinearVoiLookupTableCommand();
                            MinMaxBitsCommand minMaxBits = new MinMaxBitsCommand();
                            MinMaxValuesCommand minMaxValues = new MinMaxValuesCommand();
                            if (ADJUST_WOB)
                                command.Flags = VoiLookupTableCommandFlags.ReverseOrder;
                            else
                                command.Flags = VoiLookupTableCommandFlags.None;

                            minMaxBits.Run(_CurrCell.Image);
                            _CurrCell.Image.LowBit = minMaxBits.MinimumBit;
                            _CurrCell.Image.HighBit = minMaxBits.MaximumBit;
                            minMaxValues.Run(_CurrCell.Image);
                            command.Width = WW;
                            command.Center = WC;
                            command.Run(_CurrCell.Image);
                            _CurrCell.Invalidate();
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (AllowAppliedWL)
                {
                    _DicomMedicalViewer.SetWindowLevel(_CurrCell, WW, WC);
                    
                }
            }
        }