]> Creatis software - gdcm.git/blob - src/gdcmPixelWriteConvert.cxx
9258fc143d51e80b2d65e28001956a6e9fee0d51
[gdcm.git] / src / gdcmPixelWriteConvert.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmPixelWriteConvert.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/10/23 15:09:19 $
7   Version:   $Revision: 1.11 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDebug.h"
20 #include "gdcmPixelWriteConvert.h"
21
22 namespace gdcm
23 {
24 //-----------------------------------------------------------------------------
25 // Constructor / Destructor
26 /**
27  * \brief Constructor
28  */
29 PixelWriteConvert::PixelWriteConvert() 
30 {
31    ReadData     = 0;
32    ReadDataSize = 0;
33
34    UserData     = 0;
35    UserDataSize = 0;
36 }
37
38 /**
39  * \brief Destructor
40  */
41 PixelWriteConvert::~PixelWriteConvert() 
42 {
43 }
44
45 //-----------------------------------------------------------------------------
46 // Public
47 /**
48  * \brief   sets Read Data (and size)
49  * @param   data data (uint8_t is for prototyping. if your data is not uint8_t
50  *                     just cast the pointer for calling the method)
51  * @param   size data size, in bytes
52  */
53 void PixelWriteConvert::SetReadData(uint8_t *data, size_t size)
54 {
55    ReadData = data;
56    ReadDataSize = size;
57 }
58
59 /**
60  * \brief   Sets the internal pointer to the caller's inData
61  *          image representation, BUT WITHOUT COPYING THE DATA.
62  *          - 'image' Pixels are presented as C-like 2D arrays : line per line.
63  *          - 'volume'Pixels are presented as C-like 3D arrays : plane per plane 
64  * \warning Since the pixels are not copied, it is the caller's responsability
65  *          not to deallocate its data before gdcm uses them (e.g. with
66  *          the Write() method )
67  * @param   data data (uint8_t is for prototyping. if your data is not uint8_t
68  *                     just cast the pointer for calling the method)
69  * @param   size size, in bytes.
70  */
71 void PixelWriteConvert::SetUserData(uint8_t *data, size_t size)
72 {
73    UserData = data;
74    UserDataSize = size;
75 }
76
77 /**
78  * \brief   Get Data (UserData or ReadData)
79  * @return  data (uint8_t is for prototyping. if your data is 
80  *                    *not* uint8_t, just cast the returned pointer)
81  */
82 uint8_t *PixelWriteConvert::GetData()
83 {
84    if ( UserData )
85    {
86       return UserData;
87    }
88    else
89    {
90       return ReadData;
91    }
92 }
93
94 /**
95  * \brief   Get Data Size (UserData or ReadData)
96  * @return  size, in bytes.
97  */
98 size_t PixelWriteConvert::GetDataSize()
99 {
100    if ( UserData )
101    {
102       return UserDataSize;
103    }
104    else
105    {
106       return ReadDataSize;
107    }
108 }
109
110 //-----------------------------------------------------------------------------
111 // Protected
112
113 //-----------------------------------------------------------------------------
114 // Private
115
116 //-----------------------------------------------------------------------------
117 // Print
118
119 //-----------------------------------------------------------------------------
120 } // end namespace gdcm