1 /*
2  *
3  *  Copyright (C) 1996-2010, OFFIS e.V.
4  *  All rights reserved.  See COPYRIGHT file for details.
5  *
6  *  This software and supporting documentation were developed by
7  *
8  *    OFFIS e.V.
9  *    R&D Division Health
10  *    Escherweg 2
11  *    D-26121 Oldenburg, Germany
12  *
13  *
14  *  Module:  dcmimage
15  *
16  *  Author:  Joerg Riesmeier
17  *
18  *  Purpose: DicomRegister (Source)
19  *
20  */
21 
22 
23 #include "dcmtk/config/osconfig.h"
24 
25 #include "dcmtk/dcmimage/diregist.h"
26 #include "dcmtk/dcmimage/dipalimg.h"
27 #include "dcmtk/dcmimage/dirgbimg.h"
28 #include "dcmtk/dcmimage/dihsvimg.h"
29 #include "dcmtk/dcmimage/diargimg.h"
30 #include "dcmtk/dcmimage/dicmyimg.h"
31 #include "dcmtk/dcmimage/diybrimg.h"
32 #include "dcmtk/dcmimage/diyf2img.h"
33 #include "dcmtk/dcmimage/diyp2img.h"
34 #include "dcmtk/dcmimage/dicomot.h"
35 #include "dcmtk/dcmimgle/didocu.h"
36 
37 
38 /*----------------*
39  *  constructors  *
40  *----------------*/
41 
DiRegister()42 DiRegister::DiRegister()
43 {
44     DiRegisterBase::Pointer = this;
45 }
46 
47 
48 /*--------------*
49  *  destructor  *
50  *--------------*/
51 
~DiRegister()52 DiRegister::~DiRegister()
53 {
54 }
55 
56 
57 /*--------------*/
58 
createImage(const DiDocument * docu,const EI_Status status,const EP_Interpretation photo)59 DiImage *DiRegister::createImage(const DiDocument *docu,
60                                  const EI_Status status,
61                                  const EP_Interpretation photo)
62 {
63     DiImage *image = NULL;
64     switch (photo)
65     {
66         case EPI_PaletteColor:
67             image = new DiPaletteImage(docu, status);
68             break;
69         case EPI_RGB:
70             image = new DiRGBImage(docu, status);
71             break;
72         case EPI_HSV:
73             image = new DiHSVImage(docu, status);
74             break;
75         case EPI_ARGB:
76             image = new DiARGBImage(docu, status);
77             break;
78         case EPI_CMYK:
79             image = new DiCMYKImage(docu, status);
80             break;
81         case EPI_YBR_Full:
82             image = new DiYBRImage(docu, status);
83             break;
84         case EPI_YBR_Full_422:
85             image = new DiYBR422Image(docu, status);
86             break;
87         case EPI_YBR_Partial_422:
88             image = new DiYBRPart422Image(docu, status);
89             break;
90         default:
91             ;
92     }
93     return image;
94 }
95 
96 
createMonoImageData(const DiColorImage * image,const double red,const double green,const double blue)97 DiMonoPixel *DiRegister::createMonoImageData(const DiColorImage *image,
98                                              const double red,
99                                              const double green,
100                                              const double blue)
101 {
102     DiMonoPixel *inter = NULL;
103     if (image != NULL)
104     {
105         const DiColorPixel *color = image->getColorInterData();
106         if (color != NULL)
107         {
108             DiMonoModality *modality = new DiMonoModality(image->getBits());
109             if (modality != NULL)
110             {
111                 switch (color->getRepresentation())
112                 {
113                     case EPR_Uint8:
114                         inter = new DiColorMonoTemplate<Uint8>(color, modality, red, green, blue);
115                         break;
116                     case EPR_Sint8:
117                         inter = new DiColorMonoTemplate<Sint8>(color, modality, red, green, blue);
118                         break;
119                     case EPR_Uint16:
120                         inter = new DiColorMonoTemplate<Uint16>(color, modality, red, green, blue);
121                         break;
122                     case EPR_Sint16:
123                         inter = new DiColorMonoTemplate<Sint16>(color, modality, red, green, blue);
124                         break;
125                     case EPR_Uint32:
126                         inter = new DiColorMonoTemplate<Uint32>(color, modality, red, green, blue);
127                         break;
128                     case EPR_Sint32:
129                         inter = new DiColorMonoTemplate<Sint32>(color, modality, red, green, blue);
130                         break;
131                 }
132             }
133         }
134     }
135     return inter;
136 }
137