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

📄 edibinfo.h

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 H
字号:
/* ////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2004-2005 Intel Corporation. All Rights Reserved.//////*/#ifndef __EDIBINFO_H__#define __EDIBINFO_H__#include "dibinfo.h"#include "byteoutput.h"#include "edibwarning.h"class EDIBInfo : public DIBInfo{public:    EDIBInfo() {}    void AttachDiagnOutput(BDiagnOutput &diagnOutput) { m_diagnOutputPtr = diagnOutput; }    unsigned int EstimateNOfBytes() const    {        unsigned int size = InfoHeaderNOfBytes(m_style);        if(m_style == Core) size += m_palette.Size() * 3;        else                size += m_palette.Size() * 4;        size += m_rawExtension.Size();        return size;    }    template<class ByteOutput>        void Write(ByteOutput &stream,        bool checkPelsPerMeterConformance = true,        bool checkOriginConformance       = true,        bool checkPaletteConformance      = true) const    {        unsigned int nOfActualPaletteEntries = m_palette.Size();        unsigned int nOfPaddingPaletteEntries;        //        // Please, note the functions that called below        // are defined after the place of call specification.        // It's possible because they defenition placed        // before actual instantiation of template.        //        WriteInfoHeader(stream,            m_style,            m_size,            m_depth,            m_origin,            m_pelsPerMeter,            m_rawExtension,            m_rawExtension.Size(),            checkPelsPerMeterConformance,            checkOriginConformance,            checkPaletteConformance,            nOfActualPaletteEntries,            nOfPaddingPaletteEntries,            m_diagnOutputPtr);        WritePalette(stream,            m_style,            m_palette,            nOfActualPaletteEntries,            nOfPaddingPaletteEntries);    }protected:    BDiagnOutputPtr m_diagnOutputPtr;};template<class ByteOutput>inline void WriteCoreInfoHeader(    ByteOutput     &stream,    const RectSize &size,    DIBDepth        depth){    // we do not write size of structure here    stream.Write16u((Ipp16u)size.Width());    stream.Write16u((Ipp16u)size.Height());    stream.Write16u(1u);    stream.Write16u((Ipp16u)BitCount(depth));}template<class ByteOutput>inline void WriteCommonInfoHeader(    ByteOutput     &stream,    const RectSize &size,    DIBDepth        depth,    DIBOrigin       origin,    RectSize        pelsPerMeter,    unsigned int    nOfPaletteEntries){    // we do not write size of structure here    stream.Write32u(size.Width());    int height = size.Height();    if(origin == BottomLeft) stream.Write32s( height);    else                     stream.Write32s(-height);    stream.Write16u(1u);    stream.Write16u((Ipp16u)BitCount(depth));    stream.Write32u(DIB_UNCOMPRESSED);    stream.Write32u(size.Height() * LineStep(depth, size.Width()));    stream.Write32u(pelsPerMeter.Width());    stream.Write32u(pelsPerMeter.Height());    stream.Write32u(nOfPaletteEntries);    stream.Write32u(0); // all colors are important}template<class ByteOutput>inline void WriteInfoHeader(    ByteOutput      &stream,    DIBInfoStyle     style,    const RectSize  &size,    DIBDepth         depth,    DIBOrigin        origin,    const RectSize  &pelsPerMeter,    const Ipp8u     *rawExtension,    unsigned int     rawExtensionSize,    bool             checkPelsPerMeterConformance,    bool             checkOriginConformance,    bool             checkPaletteConformance,    unsigned int    &nOfActualPaletteEntries,    unsigned int    &nOfPaddingPaletteEntries,    BDiagnOutputPtr  diagnOutputPtr) //nOfPaletteEntries is returnable only{    stream.Write32u(InfoHeaderNOfBytes(style) + rawExtensionSize);    if(style == Core)    {        // possible warnings generation        if(checkPelsPerMeterConformance)            diagnOutputPtr->Warning(DiagnDescrCT<EDIBWarning, EDIBCoreInfoStylePelsPerMeterLoss>());        if(checkOriginConformance && (origin != BottomLeft) )            diagnOutputPtr->Warning(DiagnDescrCT<EDIBWarning, EDIBCoreInfoStyleOrientationLoss>());        switch(depth)        {        case Depth_8:            if(nOfActualPaletteEntries < (1 << 8))            {                if(checkPaletteConformance)                    diagnOutputPtr->Warning(DiagnDescrCT<EDIBWarning, EDIBCoreInfoStyleNOfPaletteEntriesMismatch>());                nOfPaddingPaletteEntries = (1 << 8) - nOfActualPaletteEntries;            }            else if(nOfActualPaletteEntries > (1 << 8))            {                if(checkPaletteConformance)                    diagnOutputPtr->Warning(DiagnDescrCT<EDIBWarning, EDIBCoreInfoStyleNOfPaletteEntriesMismatch>());                nOfActualPaletteEntries  = 1 << 8;                nOfPaddingPaletteEntries = 0;            }            else            {                nOfPaddingPaletteEntries = 0;            }            break;        case Depth_24:            nOfPaddingPaletteEntries = 0;            if(nOfActualPaletteEntries != 0)            {                diagnOutputPtr->Warning(DiagnDescrCT<EDIBWarning, EDIBCoreInfoStyleNOfPaletteEntriesMismatch>());                nOfActualPaletteEntries  = 0;                nOfPaddingPaletteEntries = 0;            }            break;        }        // actual writing        WriteCoreInfoHeader(stream, size, depth);    }    else    {        WriteCommonInfoHeader(stream, size, depth, origin, pelsPerMeter, nOfActualPaletteEntries);        nOfPaddingPaletteEntries = 0;    }    stream.Write(rawExtension, rawExtensionSize);}template<class ByteOutput>inline void WritePalette(    ByteOutput        &stream,    DIBInfoStyle       style,    const DIBRGBValue *palette,    unsigned int       nOfActualEntries,    unsigned int       nOfPaddingEntries){    unsigned int entry;    switch(style)    {    case Core:        for(entry = 0; entry < nOfActualEntries; entry++)        {            stream.Write8u(palette[entry].B());            stream.Write8u(palette[entry].G());            stream.Write8u(palette[entry].R());        }        for(entry = 0; entry < nOfPaddingEntries; entry++)        {            stream.Write8u(0);            stream.Write8u(0);            stream.Write8u(0);        }        break;    default:        for(entry = 0; entry < nOfActualEntries; entry++)        {            stream.Write8u(palette[entry].B());            stream.Write8u(palette[entry].G());            stream.Write8u(palette[entry].R());            stream.Write8u(0); // reserved        }        for(entry = 0; entry < nOfPaddingEntries; entry++)        {            stream.Write8u(0);            stream.Write8u(0);            stream.Write8u(0);            stream.Write8u(0); // reserved        }    }}#endif // __EDIBINFO_H__

⌨️ 快捷键说明

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