00001 /* 00002 * 00003 * Copyright (C) 1996-2004, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmimage 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: DicomColorImage (Header) 00023 * 00024 * Last Update: $Author: joergr $ 00025 * Update Date: $Date: 2004/02/06 11:18:18 $ 00026 * CVS/RCS Revision: $Revision: 1.20 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 00034 #ifndef DICOIMG_H 00035 #define DICOIMG_H 00036 00037 #include "osconfig.h" 00038 #include "dctypes.h" 00039 00040 #include "diimage.h" 00041 #include "diutils.h" 00042 00043 00044 /*------------------------* 00045 * forward declarations * 00046 *------------------------*/ 00047 00048 class DiColorPixel; 00049 class DiColorOutputPixel; 00050 00051 00052 /*---------------------* 00053 * class declaration * 00054 *---------------------*/ 00055 00058 class DiColorImage 00059 : public DiImage 00060 { 00061 00062 public: 00063 00071 DiColorImage(const DiDocument *docu, 00072 const EI_Status status, 00073 const int spp, 00074 const OFBool rgb = OFTrue); 00075 00078 virtual ~DiColorImage(); 00079 00083 virtual EP_Interpretation getInternalColorModel() const 00084 { 00085 return (RGBColorModel) ? EPI_RGB : EPI_YBR_Full; 00086 } 00087 00094 virtual unsigned long getOutputDataSize(const int bits = 0) const; 00095 00108 const void *getOutputData(const unsigned long frame, 00109 const int bits, 00110 const int planar = 0); 00111 00126 int getOutputData(void *buffer, 00127 const unsigned long size, 00128 const unsigned long frame, 00129 const int bits, 00130 const int planar = 0); 00131 00139 const void *getOutputPlane(const int plane) const; 00140 00144 void deleteOutputData(); 00145 00153 DiImage *createImage(const unsigned long fstart, 00154 const unsigned long fcount) const; 00155 00174 DiImage *createScale(const signed long left_pos, 00175 const signed long top_pos, 00176 const unsigned long src_cols, 00177 const unsigned long src_rows, 00178 const unsigned long dest_cols, 00179 const unsigned long dest_rows, 00180 const int interpolate, 00181 const int aspect, 00182 const Uint16 pvalue) const; 00183 00193 int flip(const int horz, 00194 const int vert); 00195 00203 DiImage *createFlip(const int horz, 00204 const int vert) const; 00205 00214 int rotate(const int degree); 00215 00222 DiImage *createRotate(const int degree) const; 00223 00232 DiImage *createMono(const double red, 00233 const double green, 00234 const double blue) const; 00235 00240 const DiColorPixel *getInterData() const 00241 { 00242 return InterData; 00243 } 00244 00257 unsigned long createDIB(void *&data, 00258 const unsigned long size, 00259 const unsigned long frame, 00260 const int bits, 00261 const int upsideDown, 00262 const int padding = 1); 00263 00273 unsigned long createAWTBitmap(void *&data, 00274 const unsigned long frame, 00275 const int bits); 00276 00283 int writeImageToDataset(DcmItem &dataset); 00284 00294 int writePPM(ostream &stream, 00295 const unsigned long frame, 00296 const int bits); 00297 00307 int writePPM(FILE *stream, 00308 const unsigned long frame, 00309 const int bits); 00310 00319 int writeRawPPM(FILE *stream, 00320 const unsigned long frame, 00321 const int bits); 00322 00331 int writeBMP(FILE *stream, 00332 const unsigned long frame, 00333 const int bits); 00334 00335 00336 protected: 00337 00344 DiColorImage(const DiColorImage *image, 00345 const unsigned long fstart, 00346 const unsigned long fcount); 00347 00364 DiColorImage(const DiColorImage *image, 00365 const signed long left_pos, 00366 const signed long top_pos, 00367 const Uint16 src_cols, 00368 const Uint16 src_rows, 00369 const Uint16 dest_cols, 00370 const Uint16 dest_rows, 00371 const int interpolate = 0, 00372 const int aspect = 0); 00373 00380 DiColorImage(const DiColorImage *image, 00381 const int horz, 00382 const int vert); 00383 00389 DiColorImage(const DiColorImage *image, 00390 const int degree); 00391 00396 int checkInterData(const int mode = 1); 00397 00409 const void *getData(void *buffer, 00410 const unsigned long size, 00411 const unsigned long frame, 00412 const int bits, 00413 const int planar); 00414 00420 virtual void updateImagePixelModuleAttributes(DcmItem &dataset); 00421 00423 const OFBool RGBColorModel; 00424 00426 DiColorPixel *InterData; 00427 00428 00429 private: 00430 00432 DiColorOutputPixel *OutputData; 00433 00434 // --- declarations to avoid compiler warnings 00435 00436 DiColorImage(const DiColorImage &); 00437 DiColorImage &operator=(const DiColorImage &); 00438 }; 00439 00440 00441 #endif 00442 00443 00444 /* 00445 * 00446 * CVS/RCS Log: 00447 * $Log: dicoimg.h,v $ 00448 * Revision 1.20 2004/02/06 11:18:18 joergr 00449 * Distinguish more clearly between const and non-const access to pixel data. 00450 * 00451 * Revision 1.19 2003/12/17 18:10:56 joergr 00452 * Removed leading underscore characters from preprocessor symbols (reserved 00453 * symbols). 00454 * 00455 * Revision 1.18 2003/06/12 15:09:41 joergr 00456 * Fixed inconsistent API documentation reported by Doxygen. 00457 * 00458 * Revision 1.17 2003/05/20 09:26:05 joergr 00459 * Added method returning the number of bytes required to store a single 00460 * rendered frame: getOutputDataSize(). 00461 * 00462 * Revision 1.16 2002/12/09 13:37:51 joergr 00463 * Renamed parameter/local variable to avoid name clashes with global 00464 * declaration left and/or right (used for as iostream manipulators). 00465 * 00466 * Revision 1.15 2002/08/02 15:07:02 joergr 00467 * Added function to write the current image (not only a selected frame) to a 00468 * DICOM dataset. 00469 * 00470 * Revision 1.14 2002/01/29 17:07:07 joergr 00471 * Added optional flag to the "Windows DIB" methods allowing to switch off the 00472 * scanline padding. 00473 * 00474 * Revision 1.13 2001/11/27 18:22:17 joergr 00475 * Added support for plugable output formats in class DicomImage. First 00476 * implementation is JPEG. 00477 * 00478 * Revision 1.12 2001/11/09 16:38:36 joergr 00479 * Added support for Windows BMP file format. 00480 * Enhanced and renamed createTrueColorDIB() method. 00481 * Updated/Enhanced comments. 00482 * 00483 * Revision 1.11 2001/09/28 13:55:40 joergr 00484 * Added new flag (CIF_KeepYCbCrColorModel) which avoids conversion of YCbCr 00485 * color models to RGB. 00486 * 00487 * Revision 1.10 2001/06/01 15:49:28 meichel 00488 * Updated copyright header 00489 * 00490 * Revision 1.9 2000/03/08 16:21:50 meichel 00491 * Updated copyright header. 00492 * 00493 * Revision 1.8 1999/08/25 16:58:06 joergr 00494 * Added new feature: Allow clipping region to be outside the image 00495 * (overlapping). 00496 * 00497 * Revision 1.7 1999/04/28 12:51:57 joergr 00498 * Corrected some typos, comments and formatting. 00499 * 00500 * Revision 1.6 1999/01/20 14:39:52 joergr 00501 * Added new output method to fill external memory buffer with rendered pixel 00502 * data. 00503 * 00504 * Revision 1.5 1998/11/27 13:43:29 joergr 00505 * Added methods and constructors for flipping and rotating, changed for 00506 * scaling and clipping. 00507 * 00508 * Revision 1.4 1998/07/01 08:39:18 joergr 00509 * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional 00510 * options), e.g. add copy constructors. 00511 * 00512 * Revision 1.3 1998/05/11 14:53:11 joergr 00513 * Added CVS/RCS header to each file. 00514 * 00515 * 00516 */