⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dimoopxt.h

📁 转化为DIB位图再显示出来的dicom文件C++代码
💻 H
📖 第 1 页 / 共 5 页
字号:
/* * *  Copyright (C) 1996-2005, OFFIS * *  This software and supporting documentation were developed by * *    Kuratorium OFFIS e.V. *    Healthcare Information and Communication Systems *    Escherweg 2 *    D-26121 Oldenburg, Germany * *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER. * *  Module:  dcmimgle * *  Author:  Joerg Riesmeier * *  Purpose: DicomMonoOutputPixelTemplate (Header) * *  Last Update:      $Author: meichel $ *  Update Date:      $Date: 2005/12/08 16:47:54 $ *  CVS/RCS Revision: $Revision: 1.46 $ *  Status:           $State: Exp $ * *  CVS/RCS Log at end of file * */#ifndef DIMOOPXT_H#define DIMOOPXT_H#include "dcmtk/config/osconfig.h"#include "dcmtk/ofstd/ofconsol.h"#include "dcmtk/ofstd/ofcast.h"#include "dcmtk/dcmdata/dctypes.h"#include "dcmtk/dcmimgle/dimoopx.h"#include "dcmtk/dcmimgle/diluptab.h"#include "dcmtk/dcmimgle/diovlay.h"#include "dcmtk/dcmimgle/dipxrept.h"#include "dcmtk/dcmimgle/diutils.h"#include "dcmtk/dcmimgle/didispfn.h"#include "dcmtk/dcmimgle/didislut.h"#ifdef PASTEL_COLOR_OUTPUT#include "dimcopxt.h"#endif#define INCLUDE_CMATH#include "dcmtk/ofstd/ofstdinc.h"/*---------------------* *  class declaration  * *---------------------*//** Template class to create monochrome output data */template<class T1, class T2, class T3>class DiMonoOutputPixelTemplate  : public DiMonoOutputPixel,    public DiPixelRepresentationTemplate<T3>{ public:    /** constructor     *     ** @param  buffer    storage area for the output pixel data (optional, maybe NULL)     *  @param  pixel     pointer to intermediate pixel representation     *  @param  overlays  array of overlay management objects     *  @param  vlut      VOI LUT (optional, maybe NULL)     *  @param  plut      presentation LUT (optional, maybe NULL)     *  @param  disp      display function (optional, maybe NULL)     *  @param  center    window center (optional, invalid if 'width' < 1)     *  @param  width     window width (optional, invalid if < 1)     *  @param  low       lowest pixel value for the output data (e.g. 0)     *  @param  high      highest pixel value for the output data (e.g. 255)     *  @param  columns   image's width (in pixels)     *  @param  rows      image's height     *  @param  frame     frame to be rendered     *  #param  frames    total number of frames present in intermediate representation     *  @param  pastel    flag indicating whether to use not only 'real' grayscale values (optional, experimental)     */    DiMonoOutputPixelTemplate(void *buffer,                              const DiMonoPixel *pixel,                              DiOverlay *overlays[2],                              const DiLookupTable *vlut,                              const DiLookupTable *plut,                              DiDisplayFunction *disp,                              const double center,                              const double width,                              const Uint32 low,                              const Uint32 high,                              const Uint16 columns,                              const Uint16 rows,                              const unsigned long frame,#ifdef PASTEL_COLOR_OUTPUT                              const unsigned long frames,#else                              const unsigned long /*frames*/,#endif                              const int pastel = 0)      : DiMonoOutputPixel(pixel, OFstatic_cast(unsigned long, columns) * OFstatic_cast(unsigned long, rows), frame,                          OFstatic_cast(unsigned long, fabs(OFstatic_cast(double, high - low)))),        Data(NULL),        DeleteData(buffer == NULL),        ColorData(NULL)    {        if ((pixel != NULL) && (Count > 0) && (FrameSize >= Count))        {            if (pastel)#ifdef PASTEL_COLOR_OUTPUT                color(buffer, pixel, frame, frames);#else            {                ofConsole.lockCerr() << "WARNING: pastel color output not supported !" << endl;                ofConsole.unlockCerr();            }#endif            else            {                Data = OFstatic_cast(T3 *, buffer);                if ((vlut != NULL) && (vlut->isValid()))            // valid VOI LUT ?                    voilut(pixel, frame * FrameSize, vlut, plut, disp, OFstatic_cast(T3, low), OFstatic_cast(T3, high));                else                {                    if (width < 1)                                  // no valid window according to supplement 33                        nowindow(pixel, frame * FrameSize, plut, disp, OFstatic_cast(T3, low), OFstatic_cast(T3, high));                    else                        window(pixel, frame * FrameSize, plut, disp, center, width, OFstatic_cast(T3, low), OFstatic_cast(T3, high));                }                overlay(overlays, disp, columns, rows, frame);      // add (visible) overlay planes to output bitmap            }        }    }    /** destructor     */    virtual ~DiMonoOutputPixelTemplate()    {        if (DeleteData)            delete[] Data;        delete ColorData;    }    /** get integer representation of output data     *     ** @return integer representation     */    inline EP_Representation getRepresentation() const    {        return DiPixelRepresentationTemplate<T3>::getRepresentation();    }    /** get size of one pixel / item in the pixel array     *     ** @return item size     */    inline size_t getItemSize() const    {        return (ColorData != NULL) ? ColorData->getItemSize() : sizeof(T3);    }    /** get pointer to output pixel data     *     ** @return pointer to pixel data     */    inline const void *getData() const    {        return (ColorData != NULL) ? ColorData->getData() : OFstatic_cast(const void *, Data);    }    /** get pointer to output pixel data     *     ** @return pointer to pixel data     */    virtual void *getDataPtr()    {        return (ColorData != NULL) ? ColorData->getDataPtr() : OFstatic_cast(void *, Data);    }    /** remove reference to (internally handled) pixel data (abstract)     */    inline void removeDataReference()    {        Data = NULL;        DeleteData = 0;    }    /** write pixel data of selected frame to PPM/ASCII file     *     ** @param  stream  open C++ output stream     *     ** @return status, true if successful, false otherwise     */    inline int writePPM(ostream &stream) const    {        if (Data != NULL)        {            register unsigned long i;            for (i = 0; i < FrameSize; ++i)                stream << OFstatic_cast(unsigned long, Data[i]) << " ";    // typecast to resolve problems with 'char'            return 1;        }        if (ColorData != NULL)            return ColorData->writePPM(stream);        return 0;    }    /** write pixel data of selected frame to PPM/ASCII file     *     ** @param  stream  open C file stream     *     ** @return status, true if successful, false otherwise     */    inline int writePPM(FILE *stream) const    {        if (Data != NULL)        {            register unsigned long i;            for (i = 0; i < FrameSize; ++i)                fprintf(stream, "%lu ", OFstatic_cast(unsigned long, Data[i]));            return 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -