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: DicomYBRImage (Source)
19  *
20  */
21 
22 
23 #include "dcmtk/config/osconfig.h"
24 
25 #include "dcmtk/dcmdata/dctypes.h"
26 
27 #include "dcmtk/dcmimage/diybrimg.h"
28 #include "dcmtk/dcmimage/diybrpxt.h"
29 #include "dcmtk/dcmimage/dilogger.h"
30 #include "dcmtk/dcmimgle/diinpx.h"
31 #include "dcmtk/dcmimgle/didocu.h"
32 
33 
34 /*----------------*
35  *  constructors  *
36  *----------------*/
37 
DiYBRImage(const DiDocument * docu,const EI_Status status)38 DiYBRImage::DiYBRImage(const DiDocument *docu,
39                        const EI_Status status)
40   : DiColorImage(docu, status, 3, !(docu->getFlags() & CIF_KeepYCbCrColorModel) /* RGBColorModel */)
41 {
42     if ((Document != NULL) && (InputData != NULL) && (ImageStatus == EIS_Normal))
43     {
44         Init();                                                 // create intermediate representation
45     }
46 }
47 
48 
49 /*--------------*
50  *  destructor  *
51  *--------------*/
52 
~DiYBRImage()53 DiYBRImage::~DiYBRImage()
54 {
55 }
56 
57 
58 /*********************************************************************/
59 
60 
Init()61 void DiYBRImage::Init()
62 {
63     /* number of pixels per plane */
64     const unsigned long planeSize = OFstatic_cast(unsigned long, Columns) * OFstatic_cast(unsigned long, Rows);
65     switch (InputData->getRepresentation())
66     {
67         case EPR_Uint8:
68             InterData = new DiYBRPixelTemplate<Uint8, Uint8>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
69             break;
70         case EPR_Sint8:
71             InterData = new DiYBRPixelTemplate<Sint8, Uint8>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
72             break;
73         case EPR_Uint16:
74             InterData = new DiYBRPixelTemplate<Uint16, Uint16>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
75             break;
76         case EPR_Sint16:
77             InterData = new DiYBRPixelTemplate<Sint16, Uint16>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
78             break;
79         case EPR_Uint32:
80             InterData = new DiYBRPixelTemplate<Uint32, Uint32>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
81             break;
82         case EPR_Sint32:
83             InterData = new DiYBRPixelTemplate<Sint32, Uint32>(Document, InputData, ImageStatus, planeSize, BitsPerSample, RGBColorModel);
84             break;
85     }
86     deleteInputData();
87     checkInterData();
88 }
89 
90 
91 /*********************************************************************/
92 
93 
processNextFrames(const unsigned long fcount)94 int DiYBRImage::processNextFrames(const unsigned long fcount)
95 {
96     if (DiImage::processNextFrames(fcount))
97     {
98         delete InterData;
99         InterData = NULL;
100         Init();
101         return (ImageStatus == EIS_Normal);
102     }
103     return 0;
104 }
105