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

📄 dicoopxt.h

📁 转化为DIB位图再显示出来的dicom文件C++代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * *  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: DicomColorOutputPixelTemplate (Header) * *  Last Update:      $Author: meichel $ *  Update Date:      $Date: 2005/12/08 16:01:33 $ *  CVS/RCS Revision: $Revision: 1.24 $ *  Status:           $State: Exp $ * *  CVS/RCS Log at end of file * */#ifndef DICOOPXT_H#define DICOOPXT_H#include "dcmtk/config/osconfig.h"#include "dcmtk/dcmdata/dctypes.h"#include "dcmtk/dcmimage/dicoopx.h"#include "dcmtk/dcmimage/dicopx.h"#include "dcmtk/dcmimgle/dipxrept.h"#include "dcmtk/dcmimgle/diutils.h"/*---------------------* *  class declaration  * *---------------------*//** Template class to create color output data */template<class T1, class T2>class DiColorOutputPixelTemplate  : public DiColorOutputPixel,    public DiPixelRepresentationTemplate<T2>{ public:    /** constructor     *     ** @param  buffer   storage area for the output pixel data (optional, maybe NULL)     *  @param  pixel    pointer to intermediate pixel representation (color)     *  @param  count    number of pixels per frame     *  @param  frame    frame to be rendered     *  @param  bits1    bit depth of input data (intermediate)     *  @param  bits2    bit depth of output data     *  @param  planar   flag indicating whether data shall be stored color-by-pixel or color-by-plane     *  @param  inverse  invert pixel data if true (0/0/0 = white)     */    DiColorOutputPixelTemplate(void *buffer,                               const DiColorPixel *pixel,                               const unsigned long count,                               const unsigned long frame,                               const int bits1, /* input depth */                               const int bits2, /* output depth */                               const int planar,                               const int inverse)      : DiColorOutputPixel(pixel, count, frame),        Data(NULL),        DeleteData(buffer == NULL),        isPlanar(planar)    {        if ((pixel != NULL) && (Count > 0) && (FrameSize >= Count))        {            Data = OFstatic_cast(T2 *, buffer);            convert(OFstatic_cast(const T1 **, OFconst_cast(void *, pixel->getData())), frame * FrameSize, bits1, bits2, planar, inverse);        }    }    /** constructor     *     ** @param  buffer  storage area for the output pixel data (optional, maybe NULL)     *  @param  pixel   pointer to intermediate pixel representation     *  @param  count   number of pixels per frame     *  @param  frame   frame to be rendered     *  #param  frames  (total number of frames present in intermediate representation)     *  @param  planar  flag indicating whether data shall be stored color-by-pixel or color-by-plane     */    DiColorOutputPixelTemplate(void *buffer,                               const DiPixel *pixel,                               const unsigned long count,                               const unsigned long frame,                               const unsigned long /*frames*/,                               const int planar)      : DiColorOutputPixel(pixel, count, frame),        Data(NULL),        DeleteData(buffer == NULL),        isPlanar(planar)    {        if ((pixel != NULL) && (Count > 0) && (FrameSize >= Count))            Data = OFstatic_cast(T2 *, buffer);    }    /** destructor     */    virtual ~DiColorOutputPixelTemplate()    {        if (DeleteData)            delete[] Data;    }    /** get integer representation     *     ** @return integer representation     */    inline EP_Representation getRepresentation() const    {        return DiPixelRepresentationTemplate<T2>::getRepresentation();    }    /** get size of one pixel / item in the pixel array     *     ** @return item size     */    inline size_t getItemSize() const    {        return sizeof(T2) * 3;    }    /** get pointer to output pixel data     *     ** @return pointer to pixel data     */    inline const void *getData() const    {        return OFstatic_cast(const void *, Data);    }    /** get pointer to output pixel data     *     ** @return pointer to pixel data     */    virtual void *getDataPtr()    {        return OFstatic_cast(void *, Data);    }    /** get pointer to given plane of output pixel data     *     ** @param  plane  number of the plane to be retrieved (0..2)     *     ** @return pointer to beginning of plane if sucessful, NULL otherwise     */    inline const void *getPlane(const int plane) const    {        void *result = NULL;        if (Data != NULL)        {            if (plane <= 0)                result = OFstatic_cast(void *, Data);            else            {                if (isPlanar)                    result = OFstatic_cast(void *, Data + ((plane == 1) ? 1 : 2) * FrameSize);                else                    result = OFstatic_cast(void *, Data + ((plane == 1) ? 1 : 2));            }        }        return result;    }    /** write pixel data of selected frame to PPM/ASCII file     *     ** @param  stream  open C++ output stream     *     ** @return status, true if successful, false otherwise     */    int writePPM(ostream &stream) const    {        if (Data != NULL)        {            register T2 *p = Data;            register unsigned long i;            register int j;            for (i = FrameSize; i != 0; --i)                for (j = 3; j != 0; --j)                    stream << OFstatic_cast(unsigned long, *(p++)) << " ";     // typecast to resolve problems with 'char'            return 1;        }        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     */    int writePPM(FILE *stream) const    {        if (Data != NULL)        {            register T2 *p = Data;            register unsigned long i;            register int j;            for (i = FrameSize; i != 0; --i)                for (j = 3; j != 0; --j)                    fprintf(stream, "%lu ", OFstatic_cast(unsigned long, *(p++)));            return 1;        }        return 0;    } protected:    /// pointer to the storage area where the output data should be stored    T2 *Data; private:    /** convert intermediate pixel data to output format (render pixel data)     *     ** @param  pixel    pointer to intermediate pixel representation (color)     *  @param  start    offset to first pixel to be converted     *  @param  bits1    bit depth of input data (intermediate)     *  @param  bits2    bit depth of output data     *  @param  planar   flag indicating whether data shall be stored color-by-pixel or color-by-plane     *  @param  inverse  invert pixel data if true (0/0/0 = white)     */    void convert(const T1 *pixel[3],                 const unsigned long start,                 const int bits1,                 const int bits2,                 const int planar,                 const int inverse)    {        if ((pixel[0] != NULL) && (pixel[1] != NULL) && (pixel[2] != NULL))        {            if (Data == NULL)                Data = new T2[FrameSize * 3];            if (Data != NULL)            {                register T2 *q = Data;

⌨️ 快捷键说明

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