1 /* 2 * 3 * Copyright (C) 1996-2001, OFFIS 4 * 5 * This software and supporting documentation were developed by 6 * 7 * Kuratorium OFFIS e.V. 8 * Healthcare Information and Communication Systems 9 * Escherweg 2 10 * D-26121 Oldenburg, Germany 11 * 12 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 13 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 14 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 15 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 16 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 17 * 18 * Module: dcmimgle 19 * 20 * Author: Joerg Riesmeier 21 * 22 * Purpose: DicomMonochromeCopyTemplate (Header) 23 * 24 */ 25 26 27 #ifndef __DIMOCPT_H 28 #define __DIMOCPT_H 29 30 #include "osconfig.h" 31 #include "dctypes.h" 32 #include "ofbmanip.h" 33 34 #include "dimopxt.h" 35 36 37 /*---------------------* 38 * class declaration * 39 *---------------------*/ 40 41 /** Template class to copy monochrome pixel data 42 */ 43 template<class T> 44 class DiMonoCopyTemplate 45 : public DiMonoPixelTemplate<T> 46 { 47 public: 48 49 /** constructor 50 * 51 ** @param pixel pointer to monochrome intermediate representation of pixel data 52 * @param fstart first frame to be copied 53 * @param fcount number of frames to be copied 54 * @param fsize size of one frame (in bytes) 55 */ DiMonoCopyTemplate(const DiMonoPixel * pixel,const unsigned long fstart,const unsigned long fcount,const unsigned long fsize)56 DiMonoCopyTemplate(const DiMonoPixel *pixel, 57 const unsigned long fstart, 58 const unsigned long fcount, 59 const unsigned long fsize) 60 : DiMonoPixelTemplate<T>(pixel, fcount * fsize) 61 { 62 if ((pixel != NULL) && (pixel->getCount() > 0)) 63 { 64 if ((pixel->getCount() > fstart * fsize) && (pixel->getCount() >= (fstart + fcount) * fsize)) 65 copy((const T *)pixel->getData() + fstart * fsize); 66 } 67 } 68 69 /** destructor 70 */ ~DiMonoCopyTemplate()71 ~DiMonoCopyTemplate() 72 { 73 } 74 75 76 private: 77 78 /** copy specified amount of pixel data 79 * 80 ** @param pixel array of pixel data to be copied 81 */ copy(const T * pixel)82 inline void copy(const T *pixel) 83 { 84 if (pixel != NULL) 85 { 86 this->Data = new T[this->getCount()]; 87 if (this->Data != NULL) 88 OFBitmanipTemplate<T>::copyMem(pixel, this->Data, this->getCount()); 89 } 90 } 91 }; 92 93 94 #endif 95