📄 dccodec.h
字号:
/* * * Copyright (C) 1994-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: dcmdata * * Author: Andreas Barth * * Purpose: Interface of abstract class DcmCodec and the class DcmCodecStruct * * Last Update: $Author: meichel $ * Update Date: $Date: 2005/12/09 14:48:14 $ * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dccodec.h,v $ * CVS/RCS Revision: $Revision: 1.18 $ * Status: $State: Exp $ * * CVS/RCS Log at end of file * */#ifndef DCCODEC_H#define DCCODEC_H#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */#include "dcmtk/dcmdata/dctypes.h"#include "dcmtk/dcmdata/dcerror.h"#include "dcmtk/dcmdata/dcxfer.h"#include "dcmtk/ofstd/oflist.h"class DcmStack;class DcmRepresentationParameter;class DcmPixelSequence;class DcmPolymorphOBOW;class DcmItem;class DcmTagKey;/** abstract base class for a codec parameter object that * describes the settings (modes of operations) for one * particular codec (DcmCodec) object. */class DcmCodecParameter{public: /// default constructor DcmCodecParameter() {} /// copy constructor DcmCodecParameter(const DcmCodecParameter&) {} /// destructor virtual ~DcmCodecParameter() {} /** this methods creates a copy of type DcmCodecParameter * * it must be overweritten in every subclass. * @return copy of this object */ virtual DcmCodecParameter *clone() const = 0; /** returns the class name as string. * can be used as poor man's RTTI replacement. */ virtual const char *className() const = 0;}; /** abstract base class for a codec object that can be registered * in dcmdata and performs transfer syntax transformation (i.e. * compressing, decompressing or transcoding between different * compressed transfer syntaxes). * When dcmdata is requested to write a transfer syntax that differs * from the current one (i.e. the one in which the object was read), * dcmdata dynamically searches for a DcmCodec object that is able * to create the desired transfer syntax. If no suitable codec * is found, the write operation fails. */class DcmCodec{public: /// default constructor DcmCodec() {} /// destructor virtual ~DcmCodec() {} /** decompresses the given pixel sequence and * stores the result in the given uncompressedPixelData element. * @param fromRepParam current representation parameter of compressed data, may be NULL * @param pixSeq compressed pixel sequence * @param uncompressedPixelData uncompressed pixel data stored in this element * @param cp codec parameters for this codec * @param objStack stack pointing to the location of the pixel data * element in the current dataset. * @return EC_Normal if successful, an error code otherwise. */ virtual OFCondition decode( const DcmRepresentationParameter * fromRepParam, DcmPixelSequence * pixSeq, DcmPolymorphOBOW& uncompressedPixelData, const DcmCodecParameter * cp, const DcmStack& objStack) const = 0; /** compresses the given uncompressed DICOM image and stores * the result in the given pixSeq element. * @param pixelData pointer to the uncompressed image data in OW format * and local byte order * @param length of the pixel data field in bytes * @param toRepParam representation parameter describing the desired * compressed representation (e.g. JPEG quality) * @param pixSeq compressed pixel sequence (pointer to new DcmPixelSequence object * allocated on heap) returned in this parameter upon success. * @param cp codec parameters for this codec * @param objStack stack pointing to the location of the pixel data * element in the current dataset. * @return EC_Normal if successful, an error code otherwise. */ virtual OFCondition encode( const Uint16 * pixelData, const Uint32 length, const DcmRepresentationParameter * toRepParam, DcmPixelSequence * & pixSeq, const DcmCodecParameter *cp, DcmStack & objStack) const = 0; /** transcodes (re-compresses) the given compressed DICOM image and stores * the result in the given toPixSeq element. * @param fromRepType current transfer syntax of the compressed image * @param fromRepParam current representation parameter of compressed data, may be NULL * @param fromPixSeq compressed pixel sequence * @param toRepParam representation parameter describing the desired * new compressed representation (e.g. JPEG quality) * @param toPixSeq compressed pixel sequence (pointer to new DcmPixelSequence object * allocated on heap) returned in this parameter upon success. * @param cp codec parameters for this codec * @param objStack stack pointing to the location of the pixel data * element in the current dataset. * @return EC_Normal if successful, an error code otherwise. */ virtual OFCondition encode( const E_TransferSyntax fromRepType, const DcmRepresentationParameter * fromRepParam, DcmPixelSequence * fromPixSeq, const DcmRepresentationParameter * toRepParam, DcmPixelSequence * & toPixSeq, const DcmCodecParameter * cp, DcmStack & objStack) const = 0; /** checks if this codec is able to convert from the * given current transfer syntax to the given new * transfer syntax * @param oldRepType current transfer syntax * @param newRepType desired new transfer syntax * @return true if transformation is supported by this codec, false otherwise. */ virtual OFBool canChangeCoding( const E_TransferSyntax oldRepType, const E_TransferSyntax newRepType) const = 0; // static helper methods that have proven useful in codec classes derived from DcmCodec /** helper function that inserts a string attribute with a given value into a dataset * if missing in the dataset. * @param dataset dataset to insert to, must not be NULL. * @param tag tag key of attribute to check/insert * @param val string value, may be NULL. * @return EC_Normal if successful, an error code otherwise */ static OFCondition insertStringIfMissing(DcmItem *dataset, const DcmTagKey& tag, const char *val); /** helper function that converts a dataset containing a DICOM image * into a valid (standard extended) Secondary Capture object * by inserting all attributes that are type 1/2 in Secondary Capture * and missing in the source dataset. Replaces SOP Class UID * by Secondary Capture. It does not, however, change an existing SOP Instance UID. * @param dataset dataset to insert to, must not be NULL. * @return EC_Normal if successful, an error code otherwise */ static OFCondition convertToSecondaryCapture(DcmItem *dataset); /** create new SOP instance UID and Source Image Sequence * referencing the old SOP instance (if present) * @param dataset dataset to be modified * @param purposeOfReferenceCodingScheme coding scheme designator for purpose of reference code sequence * @param purposeOfReferenceCodeValue code value for purpose of reference code sequence * @param purposeOfReferenceCodeMeaning code meaning for purpose of reference code sequence * @return EC_Normal if successful, an error code otherwise */ static OFCondition newInstance( DcmItem *dataset, const char *purposeOfReferenceCodingScheme = NULL, const char *purposeOfReferenceCodeValue = NULL, const char *purposeOfReferenceCodeMeaning = NULL); /** set first value of Image Type to DERIVED. * @param dataset dataset to be modified * @return EC_Normal if successful, an error code otherwise */ static OFCondition updateImageType(DcmItem *dataset); /** insert code sequence into the given dataset * @param dataset dataset to insert into * @param tagKey tag of the code sequence * @param codingSchemeDesignator coding scheme designator for the sequence item * @param codeValue code value for the sequence item * @param codeMeaning code meaning for the sequence item * @return EC_Normal if successul, an error code otherwise */ static OFCondition insertCodeSequence( DcmItem *dataset, const DcmTagKey &tagKey, const char *codingSchemeDesignator, const char *codeValue, const char *codeMeaning);};/** singleton that keeps list of registered codecs for dcmdata. * All operations on the list are protected by a read/write lock * and, therefore, are safe for multi-thread applications. */class DcmCodecList{public: /// destructor virtual ~DcmCodecList();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -