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 "osconfig.h"
00038
#include "dctypes.h"
00039
#include "ofglobal.h"
00040
#include "ofcast.h"
00041
00042
#define INCLUDE_CSTDLIB
00043
#define INCLUDE_CSTDIO
00044
#include "ofstdinc.h"
00045
00046 BEGIN_EXTERN_C
00047
#ifdef HAVE_LIBC_H
00048
#include <libc.h>
00049
#endif
00050
END_EXTERN_C
00051
00052
00053
00054
00055
00056
00061
00063
const unsigned long CIF_AcrNemaCompatibility = 0x0000001;
00064
00066
const unsigned long CIF_WrongPaletteAttributeTags = 0x0000002;
00067
00069
const unsigned long CIF_MayDetachPixelData = 0x0000004;
00070
00072
const unsigned long CIF_UsePresentationState = 0x0000008;
00073
00075
const unsigned long CIF_KeepYCbCrColorModel = 0x0000010;
00076
00078
const unsigned long CIF_TakeOverExternalDataset = 0x0000020;
00079
00081
const unsigned long CIF_IgnoreModalityTransformation = 0x0000040;
00082
00084
const unsigned long CIF_IgnoreModalityLutBitDepth = 0x0000080;
00086
00087
00088
00089
const int MI_PastelColor = -1;
00090
00091
00092
00093
00094
00095
00098
enum EP_Interpretation
00099 {
00101 EPI_Unknown,
00103 EPI_Monochrome1,
00105 EPI_Monochrome2,
00107 EPI_PaletteColor,
00109 EPI_RGB,
00111 EPI_HSV,
00113 EPI_ARGB,
00115 EPI_CMYK,
00117 EPI_YBR_Full,
00119 EPI_YBR_Full_422,
00121 EPI_YBR_Partial_422
00122 };
00123
00124
00127 struct SP_Interpretation
00128 {
00130 const char *
Name;
00132 EP_Interpretation
Type;
00133 };
00134
00135
00138 struct SB_BitmapFileHeader
00139 {
00141 char bfType[2];
00143 Uint32
bfSize;
00145 Uint16
bfReserved1;
00147 Uint16
bfReserved2;
00149 Uint32
bfOffBits;
00150 };
00151
00152
00155 struct SB_BitmapInfoHeader
00156 {
00158 Uint32
biSize;
00160 Sint32
biWidth;
00162 Sint32
biHeight;
00164 Uint16
biPlanes;
00166 Uint16
biBitCount;
00168 Uint32
biCompression;
00170 Uint32
biSizeImage;
00172 Sint32
biXPelsPerMeter;
00174 Sint32
biYPelsPerMeter;
00176 Uint32
biClrUsed;
00178 Uint32
biClrImportant;
00179 };
00180
00181
00184
enum EP_Representation
00185 {
00187 EPR_Uint8, EPR_MinUnsigned = EPR_Uint8,
00189 EPR_Sint8, EPR_MinSigned = EPR_Sint8,
00191 EPR_Uint16,
00193 EPR_Sint16,
00195 EPR_Uint32, EPR_MaxUnsigned = EPR_Uint32,
00197 EPR_Sint32, EPR_MaxSigned = EPR_Sint32
00198 };
00199
00200
00203
enum EI_Status
00204 {
00206 EIS_Normal,
00208 EIS_NoDataDictionary,
00210 EIS_InvalidDocument,
00212 EIS_MissingAttribute,
00214 EIS_InvalidValue,
00216 EIS_NotSupportedValue,
00218 EIS_MemoryFailure,
00220 EIS_InvalidImage,
00222 EIS_OtherError
00223 };
00224
00225
00229
enum EM_Overlay
00230 {
00232 EMO_Default,
00234 EMO_Replace,
00236 EMO_Graphic = EMO_Replace,
00238 EMO_ThresholdReplace,
00240 EMO_Complement,
00242 EMO_RegionOfInterest,
00244 EMO_BitmapShutter
00245 };
00246
00247
00250
enum ES_PresentationLut
00251 {
00253 ESP_Default,
00255 ESP_Identity,
00257 ESP_Inverse,
00259 ESP_LinOD
00260 };
00261
00262
00265
enum EP_Polarity
00266 {
00268 EPP_Normal,
00270 EPP_Reverse
00271 };
00272
00273
00274
00275
00276
00277
00278
const SP_Interpretation PhotometricInterpretationNames[] =
00279 {
00280 {
"MONOCHROME1", EPI_Monochrome1},
00281 {
"MONOCHROME2", EPI_Monochrome2},
00282 {
"PALETTECOLOR", EPI_PaletteColor},
00283 {
"RGB", EPI_RGB},
00284 {
"HSV", EPI_HSV},
00285 {
"ARGB", EPI_ARGB},
00286 {
"CMYK", EPI_CMYK},
00287 {
"YBRFULL", EPI_YBR_Full},
00288 {
"YBRFULL422", EPI_YBR_Full_422},
00289 {
"YBRPARTIAL422", EPI_YBR_Partial_422},
00290 {NULL, EPI_Unknown}
00291 };
00292
00293
00294
00295
00296
00297
00298
#define MAX_UINT Uint32
00299
#define MAX_SINT Sint32
00300
00301
#define MAX_BITS 32
00302
#define MAX_RAWPPM_BITS 8
00303
#define MAX_INTERPOLATION_BITS 16
00304
00305
#define bitsof(expr) (sizeof(expr) << 3)
00306
00307
00308
00309
00310
00311
00315 class DicomImageClass
00316 {
00317
00318
public:
00319
00327 static inline unsigned long maxval(
const int mv_bits,
00328
const unsigned long mv_pos = 1)
00329 {
00330
return (mv_bits < MAX_BITS) ? (OFstatic_cast(
unsigned long, 1) << mv_bits) - mv_pos : OFstatic_cast(
unsigned long, -1);
00331 }
00332
00340 static inline unsigned int tobits(
unsigned long tb_value,
00341
const unsigned long tb_pos = 1)
00342 {
00343
if (tb_value > 0)
00344 tb_value -= tb_pos;
00345
register unsigned int tb_bits = 0;
00346
while (tb_value > 0)
00347 {
00348 ++tb_bits;
00349 tb_value >>= 1;
00350 }
00351
return tb_bits;
00352 }
00353
00361
static EP_Representation
determineRepresentation(
double minvalue,
00362
double maxvalue);
00363
00368 static void setDebugLevel(
const int level)
00369 {
00370
DebugLevel.
set(level);
00371 }
00372
00377 static int getDebugLevel()
00378 {
00379
return DebugLevel.
get();
00380 }
00381
00388 static int checkDebugLevel(
const int level)
00389 {
00390
return DebugLevel.
get() & level;
00391 }
00392
00393
00395 static const int DL_NoMessages;
00397 static const int DL_Errors;
00399 static const int DL_Warnings;
00401 static const int DL_Informationals;
00403 static const int DL_DebugMessages;
00404
00405
00406
private:
00407
00409 static OFGlobal<int> DebugLevel;
00410 };
00411
00412
00413
#endif
00414
00415
00416
00417
00418
00419
00420
00421
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