1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/*
*
* Copyright (C) 2003-2016, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmdata
*
* Author: Joerg Riesmeier
*
* Purpose: Implementation of DICOMDIR image support (plugin)
*
*/
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmjpeg/ddpiimpl.h"
#include "dcmtk/dcmimgle/dcmimage.h" /* for class DicomImage */
#include "dcmtk/dcmimgle/discalet.h" /* for direct image scaling */
#include "dcmtk/ofstd/ofcast.h"
/*------------------*
* implementation *
*------------------*/
// constructor
DicomDirImageImplementation::DicomDirImageImplementation()
{
}
// destructor
DicomDirImageImplementation::~DicomDirImageImplementation()
{
}
// scale pixel data
OFBool DicomDirImageImplementation::scaleData(const Uint8 *srcData,
const unsigned int srcWidth,
const unsigned int srcHeight,
Uint8 *dstData,
const unsigned int dstWidth,
const unsigned int dstHeight) const
{
OFBool result = OFFalse;
/* check parameters (at least the pointers) */
if ((srcData != NULL) && (dstData != NULL))
{
DiScaleTemplate<Uint8> scale(1, OFstatic_cast(Uint16, srcWidth), OFstatic_cast(Uint16, srcHeight),
OFstatic_cast(Uint16, dstWidth), OFstatic_cast(Uint16, dstHeight), 1);
scale.scaleData(OFstatic_cast(const Uint8 **, &srcData), &dstData, 1 /* interpolate */);
result = OFTrue;
}
return result;
}
// get scaled pixel data from DICOM image (monochrome only)
OFBool DicomDirImageImplementation::scaleImage(DcmItem *dataset,
Uint8 *pixel,
const unsigned long count,
const unsigned long frame,
const unsigned int width,
const unsigned int height,
const OFBool decompressAll) const
{
OFBool result = OFFalse;
/* check parameters (at least the pointers) */
if ((dataset != NULL) && (pixel != NULL) && (frame > 0))
{
unsigned long flags = CIF_UsePartialAccessToPixelData | CIF_NeverAccessEmbeddedOverlays;
if (decompressAll)
flags |= CIF_DecompressCompletePixelData;
/* open referenced image */
DicomImage *image = new DicomImage(dataset, EXS_Unknown, flags, frame - 1 /*fstart*/, 1 /*fcount*/);
if ((image != NULL) && (image->getStatus() == EIS_Normal))
{
/* check if image is monochrome */
if (!image->isMonochrome())
{
/* ... if not create one */
DicomImage *mono = image->createMonochromeImage();
/* replace image by monochrome one */
delete image;
image = mono;
}
if (image != NULL)
{
/* create icon */
DicomImage *scaled = image->createScaledImage(OFstatic_cast(unsigned long, width),
OFstatic_cast(unsigned long, height), 1 /*interpolate*/);
if (scaled != NULL)
{
/* set VOI window */
if (!scaled->setWindow(0))
scaled->setMinMaxWindow();
/* get pixel data */
void *data = OFstatic_cast(void *, pixel);
if (scaled->getOutputData(data, count, 8))
result = OFTrue;
delete scaled;
}
}
}
delete image;
}
return result;
}
|