00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef DIUTILS_H
00035 #define DIUTILS_H
00036
00037 #include "dcmtk/config/osconfig.h"
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/ofstd/ofglobal.h"
00040 #include "dcmtk/ofstd/ofcast.h"
00041
00042 #define INCLUDE_CSTDLIB
00043 #define INCLUDE_CSTDIO
00044 #define INCLUDE_LIBC
00045 #include "dcmtk/ofstd/ofstdinc.h"
00046
00047
00048
00049
00050
00055
00057 const unsigned long CIF_AcrNemaCompatibility = 0x0000001;
00058
00060 const unsigned long CIF_WrongPaletteAttributeTags = 0x0000002;
00061
00063 const unsigned long CIF_MayDetachPixelData = 0x0000004;
00064
00066 const unsigned long CIF_UsePresentationState = 0x0000008;
00067
00069 const unsigned long CIF_KeepYCbCrColorModel = 0x0000010;
00070
00072 const unsigned long CIF_TakeOverExternalDataset = 0x0000020;
00073
00075 const unsigned long CIF_IgnoreModalityTransformation = 0x0000040;
00076
00078 const unsigned long CIF_IgnoreModalityLutBitDepth = 0x0000080;
00080
00081
00082
00083 const int MI_PastelColor = -1;
00084
00085
00086
00087
00088
00089
00092 enum EP_Interpretation
00093 {
00095 EPI_Unknown,
00097 EPI_Monochrome1,
00099 EPI_Monochrome2,
00101 EPI_PaletteColor,
00103 EPI_RGB,
00105 EPI_HSV,
00107 EPI_ARGB,
00109 EPI_CMYK,
00111 EPI_YBR_Full,
00113 EPI_YBR_Full_422,
00115 EPI_YBR_Partial_422
00116 };
00117
00118
00121 struct SP_Interpretation
00122 {
00124 const char *Name;
00126 EP_Interpretation Type;
00127 };
00128
00129
00132 struct SB_BitmapFileHeader
00133 {
00135 char bfType[2];
00137 Uint32 bfSize;
00139 Uint16 bfReserved1;
00141 Uint16 bfReserved2;
00143 Uint32 bfOffBits;
00144 };
00145
00146
00149 struct SB_BitmapInfoHeader
00150 {
00152 Uint32 biSize;
00154 Sint32 biWidth;
00156 Sint32 biHeight;
00158 Uint16 biPlanes;
00160 Uint16 biBitCount;
00162 Uint32 biCompression;
00164 Uint32 biSizeImage;
00166 Sint32 biXPelsPerMeter;
00168 Sint32 biYPelsPerMeter;
00170 Uint32 biClrUsed;
00172 Uint32 biClrImportant;
00173 };
00174
00175
00178 enum EP_Representation
00179 {
00181 EPR_Uint8, EPR_MinUnsigned = EPR_Uint8,
00183 EPR_Sint8, EPR_MinSigned = EPR_Sint8,
00185 EPR_Uint16,
00187 EPR_Sint16,
00189 EPR_Uint32, EPR_MaxUnsigned = EPR_Uint32,
00191 EPR_Sint32, EPR_MaxSigned = EPR_Sint32
00192 };
00193
00194
00197 enum EI_Status
00198 {
00200 EIS_Normal,
00202 EIS_NoDataDictionary,
00204 EIS_InvalidDocument,
00206 EIS_MissingAttribute,
00208 EIS_InvalidValue,
00210 EIS_NotSupportedValue,
00212 EIS_MemoryFailure,
00214 EIS_InvalidImage,
00216 EIS_OtherError
00217 };
00218
00219
00223 enum EM_Overlay
00224 {
00226 EMO_Default,
00228 EMO_Replace,
00230 EMO_Graphic = EMO_Replace,
00232 EMO_ThresholdReplace,
00234 EMO_Complement,
00236 EMO_InvertBitmap,
00238 EMO_RegionOfInterest,
00240 EMO_BitmapShutter
00241 };
00242
00243
00246 enum ES_PresentationLut
00247 {
00249 ESP_Default,
00251 ESP_Identity,
00253 ESP_Inverse,
00255 ESP_LinOD
00256 };
00257
00258
00261 enum EP_Polarity
00262 {
00264 EPP_Normal,
00266 EPP_Reverse
00267 };
00268
00269
00270
00271
00272
00273
00274 const SP_Interpretation PhotometricInterpretationNames[] =
00275 {
00276 {"MONOCHROME1", EPI_Monochrome1},
00277 {"MONOCHROME2", EPI_Monochrome2},
00278 {"PALETTECOLOR", EPI_PaletteColor},
00279 {"RGB", EPI_RGB},
00280 {"HSV", EPI_HSV},
00281 {"ARGB", EPI_ARGB},
00282 {"CMYK", EPI_CMYK},
00283 {"YBRFULL", EPI_YBR_Full},
00284 {"YBRFULL422", EPI_YBR_Full_422},
00285 {"YBRPARTIAL422", EPI_YBR_Partial_422},
00286 {NULL, EPI_Unknown}
00287 };
00288
00289
00290
00291
00292
00293
00294 #define MAX_UINT Uint32
00295 #define MAX_SINT Sint32
00296
00297 #define MAX_BITS 32
00298 #define MAX_BITS_TYPE Uint32
00299 #define MAX_RAWPPM_BITS 8
00300 #define MAX_INTERPOLATION_BITS 16
00301
00302 #define bitsof(expr) (sizeof(expr) << 3)
00303
00304
00305
00306
00307
00308
00312 class DicomImageClass
00313 {
00314
00315 public:
00316
00324 static inline unsigned long maxval(const int mv_bits,
00325 const unsigned long mv_pos = 1)
00326 {
00327 return (mv_bits < MAX_BITS) ?
00328 (OFstatic_cast(unsigned long, 1) << mv_bits) - mv_pos : OFstatic_cast(MAX_BITS_TYPE, -1);
00329 }
00330
00338 static inline unsigned int tobits(unsigned long tb_value,
00339 const unsigned long tb_pos = 1)
00340 {
00341 if (tb_value > 0)
00342 tb_value -= tb_pos;
00343 register unsigned int tb_bits = 0;
00344 while (tb_value > 0)
00345 {
00346 ++tb_bits;
00347 tb_value >>= 1;
00348 }
00349 return tb_bits;
00350 }
00351
00359 static unsigned int rangeToBits(double minvalue,
00360 double maxvalue);
00361
00369 static EP_Representation determineRepresentation(double minvalue,
00370 double maxvalue);
00371
00376 static void setDebugLevel(const int level)
00377 {
00378 DebugLevel.set(level);
00379 }
00380
00385 static int getDebugLevel()
00386 {
00387 return DebugLevel.get();
00388 }
00389
00396 static int checkDebugLevel(const int level)
00397 {
00398 return DebugLevel.get() & level;
00399 }
00400
00401
00403 static const int DL_NoMessages;
00405 static const int DL_Errors;
00407 static const int DL_Warnings;
00409 static const int DL_Informationals;
00411 static const int DL_DebugMessages;
00412
00413
00414 private:
00415
00417 static OFGlobal<int> DebugLevel;
00418 };
00419
00420
00421 #endif
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546