Program.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2012-2020 fo-dicom contributors.
  2. // Licensed under the Microsoft Public License (MS-PL).
  3. using System;
  4. using System.Drawing;
  5. using Dicom.Imaging;
  6. using Dicom.Log;
  7. namespace Print_SCU
  8. {
  9. internal static class Program
  10. {
  11. private static async System.Threading.Tasks.Task Main(string[] args)
  12. {
  13. // Initialize log manager.
  14. LogManager.SetImplementation(ConsoleLogManager.Instance);
  15. var stopwatch = new System.Diagnostics.Stopwatch();
  16. stopwatch.Start();
  17. var printJob = new PrintJob("DICOM PRINT JOB")
  18. {
  19. RemoteAddress = "localhost",
  20. RemotePort = 8000,
  21. CallingAE = "PRINTSCU",
  22. CalledAE = "PRINTSCP"
  23. };
  24. //greyscale
  25. var greyscaleImg = new DicomImage(@"Data\1.3.51.5155.1353.20020423.1100947.1.0.0.dcm");
  26. using (var bitmap = greyscaleImg.RenderImage().As<Bitmap>())
  27. {
  28. printJob.StartFilmBox("STANDARD\\1,1", "PORTRAIT", "A4");
  29. printJob.FilmSession.IsColor = false; //set to true to print in color
  30. printJob.AddImage(bitmap, 0);
  31. printJob.EndFilmBox();
  32. }
  33. //color
  34. var colorImg = new DicomImage(@"Data\US-RGB-8-epicard.dcm");
  35. using (var bitmap = colorImg.RenderImage().As<Bitmap>())
  36. {
  37. printJob.StartFilmBox("STANDARD\\1,1", "PORTRAIT", "A4");
  38. printJob.FilmSession.IsColor = true; //set to true to print in color
  39. printJob.AddImage(bitmap, 0);
  40. printJob.EndFilmBox();
  41. }
  42. await printJob.Print();
  43. stopwatch.Stop();
  44. Console.WriteLine();
  45. Console.WriteLine(stopwatch.Elapsed);
  46. }
  47. }
  48. }