ctkDICOMImageTest1.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. // Qt includes
  16. #include <QApplication>
  17. #include <QLabel>
  18. // ctkDICOMCore includes
  19. #include "ctkDICOMImage.h"
  20. // DCMTK includes
  21. #include <dcmtk/dcmimgle/dcmimage.h>
  22. // STD includes
  23. #include <iostream>
  24. int ctkDICOMImageTest1( int argc, char * argv [] )
  25. {
  26. QApplication app(argc, argv);
  27. if (argc <= 1)
  28. {
  29. std::cerr << "Warning, no dicom file given. Test stops" << std::endl;
  30. std::cerr << "Usage: qctkDICOMImageTest1 <dicom file>" << std::endl;
  31. return EXIT_FAILURE;
  32. }
  33. DicomImage dcmtkImage(argv[1]);
  34. ctkDICOMImage ctkImage(&dcmtkImage);
  35. QLabel qtImage;
  36. QPixmap pixmap = QPixmap::fromImage(ctkImage.frame(0),Qt::AvoidDither);
  37. if (pixmap.isNull())
  38. {
  39. std::cerr << "Failed to convert QImage to QPixmap" ;
  40. return EXIT_FAILURE;
  41. }
  42. qtImage.setPixmap(pixmap);
  43. qtImage.show();
  44. if (argc > 2 && QString(argv[2]) == "-I")
  45. {
  46. return app.exec();
  47. }
  48. return EXIT_SUCCESS;
  49. }