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: DicomYBR422Image (Source)
19  *
20  */
21 
22 
23 #include "dcmtk/config/osconfig.h"
24 
25 #include "dcmtk/dcmdata/dctypes.h"
26 
27 #include "dcmtk/dcmimage/diyf2img.h"
28 #include "dcmtk/dcmimage/diyf2pxt.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 
DiYBR422Image(const DiDocument * docu,const EI_Status status)38 DiYBR422Image::DiYBR422Image(const DiDocument *docu,
39                              const EI_Status status)
40   : DiColorImage(docu, status, 2, !(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 
~DiYBR422Image()53 DiYBR422Image::~DiYBR422Image()
54 {
55 }
56 
57 
58 /*********************************************************************/
59 
60 
Init()61 void DiYBR422Image::Init()
62 {
63     switch (InputData->getRepresentation())
64     {
65         case EPR_Uint8:
66             InterData = new DiYBR422PixelTemplate<Uint8, Uint8>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
67             break;
68         case EPR_Sint8:
69             InterData = new DiYBR422PixelTemplate<Sint8, Uint8>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
70             break;
71         case EPR_Uint16:
72             InterData = new DiYBR422PixelTemplate<Uint16, Uint16>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
73             break;
74         case EPR_Sint16:
75             InterData = new DiYBR422PixelTemplate<Sint16, Uint16>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
76             break;
77         case EPR_Uint32:
78             InterData = new DiYBR422PixelTemplate<Uint32, Uint32>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
79             break;
80         case EPR_Sint32:
81             InterData = new DiYBR422PixelTemplate<Sint32, Uint32>(Document, InputData, ImageStatus, BitsPerSample, RGBColorModel);
82             break;
83     }
84     deleteInputData();
85     checkInterData();
86 }
87 
88 
89 /*********************************************************************/
90 
91 
processNextFrames(const unsigned long fcount)92 int DiYBR422Image::processNextFrames(const unsigned long fcount)
93 {
94     if (DiImage::processNextFrames(fcount))
95     {
96         delete InterData;
97         InterData = NULL;
98         Init();
99         return (ImageStatus == EIS_Normal);
100     }
101     return 0;
102 }
103