Esempio n. 1
0
        /// <summary>
        /// Print Page event
        /// </summary>
        private void _printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            int savePage = _viewer.Image.Page;

            try
            {
                _viewer.Image.Page = _printPage;
                _printPage++;

                using (Image img = RasterImageConverter.ConvertToImage(_viewer.Image, ConvertToImageOptions.None))
                {
                    if (DialogUtilities.CanRunPrintPreview)
                    {
                        e.Graphics.DrawImage(img, 0, 0);
                    }
                }

                e.HasMorePages = _printPage <= _viewer.Image.PageCount;
                if (_printPage > _viewer.Image.PageCount)
                {
                    _printPage = 1;
                }
            }
            finally
            {
                _viewer.Image.Page = savePage;
            }
        }
Esempio n. 2
0
        void scEngine_CaptureInformation(object sender, ScreenCaptureInformationEventArgs e)
        {
            e.Image.XResolution = e.Image.YResolution = 300;
            AnnAutomationObject customAnn   = annAutomationManager.FindObjectById(AnnObject.StampObjectId);
            AnnStampObject      customStamp = (AnnStampObject)customAnn.ObjectTemplate;

            customStamp.Text = " ";

            customStamp.Fill    = null;
            customStamp.Stroke  = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(0));;
            customStamp.Picture = new AnnPicture(RasterImageConverter.ConvertToImage(e.Image, ConvertToImageOptions.None));
        }
        private static void FillSeriesThumbnail(LoadSeriesEventArgs e, SeriesInformation seriesInfo)
        {
            if (e.LoadedSeries.Streamer.SeriesCells.Length > 0)
            {
                MedicalViewerMultiCell cell = e.LoadedSeries.Streamer.SeriesCells[0];

                if (cell.VirtualImage != null)
                {
                    if (cell.VirtualImage[cell.ActiveSubCell].ImageExist)
                    {
                        using (RasterImage image = cell.VirtualImage[cell.ActiveSubCell].Image.Clone())
                        {
                            Image thumbImage;

                            if (image.Width != 64 || image.Height != 64)
                            {
                                SizeCommand sizeCommand;


                                sizeCommand = new SizeCommand(64, 64, RasterSizeFlags.None);

                                sizeCommand.Run(image);
                            }

                            if (image.BitsPerPixel != 24)
                            {
                                ColorResolutionCommand colorRes = new ColorResolutionCommand(ColorResolutionCommandMode.InPlace,
                                                                                             24,
                                                                                             RasterByteOrder.Bgr,
                                                                                             RasterDitheringMethod.None,
                                                                                             ColorResolutionCommandPaletteFlags.FastMatch,
                                                                                             null);


                                colorRes.Run(image);
                            }

                            thumbImage = RasterImageConverter.ConvertToImage(image, ConvertToImageOptions.InitAlpha);

                            seriesInfo.Thumbnail = thumbImage;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            RasterImage image = (_imageList.ActiveItem as PDFPageItem).PageImage;

            // Get the print document object
            PrintDocument document = sender as PrintDocument;

            // Create an new LEADTOOLS image printer class
            RasterImagePrinter printer = new RasterImagePrinter();

            // Set the document object so page calculations can be performed
            printer.PrintDocument = document;

            // We want to fit and center the image into the maximum print area
            printer.SizeMode            = RasterPaintSizeMode.FitAlways;
            printer.HorizontalAlignMode = RasterPaintAlignMode.Center;
            printer.VerticalAlignMode   = RasterPaintAlignMode.Center;

            // Account for FAX images that may have different horizontal and vertical resolution
            printer.UseDpi = true;

            // Print the whole image
            printer.ImageRectangle = Rectangle.Empty;

            // Use maximum page dimension ignoring the margins, this will be equivalant of printing
            // using Windows Photo Gallery
            printer.PageRectangle = RectangleF.Empty;
            printer.UseMargins    = false;

            using (Image printImage = RasterImageConverter.ConvertToImage(image, ConvertToImageOptions.None))
            {
                using (Bitmap printBitmap = new Bitmap(printImage))
                {
                    foreach (FormFieldControl control in _imageViewer.Controls)
                    {
                        if (control.IsFieldPrintable)
                        {
                            bool isFieldVisible = control.IsFieldVisible;
                            control.IsFieldVisible = true;

                            LeadRect leadBounds = new LeadRect(control.Bounds.X, control.Bounds.Y, control.FiedlBounds.Width, control.Bounds.Height);

                            // convert from Control to Image coordinates
                            leadBounds = _imageViewer.ConvertRect(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, leadBounds);

                            Rectangle bounds = new Rectangle(leadBounds.X, leadBounds.Y, leadBounds.Width, leadBounds.Height);

                            control.DrawToBitmap(printBitmap, bounds);

                            control.IsFieldVisible = isFieldVisible;
                        }
                    }

                    image = RasterImageConverter.ConvertFromImage(printBitmap, ConvertFromImageOptions.None);
                }
            }

            // Print the current page
            printer.Print(image, _currentPrintPageNumber, e);

            // Go to the next page
            _currentPrintPageNumber++;

            // Inform the printer whether we have more pages to print
            if (_currentPrintPageNumber <= document.PrinterSettings.ToPage)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
        }