imagebits.h
来自「这是VCF框架的代码」· C头文件 代码 · 共 647 行 · 第 1/2 页
H
647 行
#ifndef _VCF_IMAGEBITS_H__#define _VCF_IMAGEBITS_H__//ImageBits.h/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*/#if _MSC_VER > 1000# pragma once#endifnamespace VCF{template < typename SizeType, bool FloatingPoint=false, bool GrayScale=false >struct PixelTraits { enum { ChannelSize = sizeof(SizeType)*8 }; typedef SizeType ChannelType; static SizeType minVal() { return FloatingPoint ? 0.0 : 0 ; } static SizeType maxVal() { return FloatingPoint ? 1.0 : ChannelSize * 8 ; } static Image::ImageChannelSize getTraitsChannelSize() { return (Image::ImageChannelSize)ChannelSize; } static Image::ImageChannelType getTraitsChannelType() { return FloatingPoint ? Image::ictFloatingPoint : Image::ictInteger; } static Image::ImageType getTraitsImageType() { return GrayScale ? Image::itGrayscale : Image::itColor; } static Image::ImageChannelSize getChannelSize( Image::ImageDescriptor val ) { return (Image::ImageChannelSize)(((val & 0xFFFF) ^ (val & 0xFF)) >> 8); } static Image::ImageDescriptor setChannelSize( Image::ImageDescriptor& val, Image::ImageChannelSize size ) { Image::ImageDescriptor tmp = (((val & 0xFFFF) ^ val) | (val & 0xFF)); val = (size << 8); val |= tmp; return val; } static Image::ImageDescriptor setImageType( Image::ImageDescriptor& val, Image::ImageType type ) { val = ((val & 0xF) ^ val) | type; return val; } static Image::ImageType getImageType( Image::ImageDescriptor val ) { return (Image::ImageType)(val & 0xF); } static Image::ImageDescriptor setChannelType( Image::ImageDescriptor& val, Image::ImageChannelType type ) { Image::ImageDescriptor tmp = (((val & 0xFFFFF) ^ val) | (val & 0xFFFF)); val = (type << 16); val |= tmp; return val; } static Image::ImageChannelType getChannelType( Image::ImageDescriptor val ) { return (Image::ImageChannelType)(((val & 0xFFFFF) ^ (val & 0xFFFF)) >> 16); } static Image::ImageDescriptor setPixelLayoutOrder( Image::ImageDescriptor& val, Image::PixelLayoutOrder order ) { Image::ImageDescriptor tmp = (((val & 0xFFFFFF) ^ val) | (val & 0xFFFFF)); val = (order << 20); val |= tmp; return val; } static Image::PixelLayoutOrder getPixelLayoutOrder( Image::ImageDescriptor val ) { return (Image::PixelLayoutOrder)(((val & 0xFFFFFF) ^ (val & 0xFFFFF)) >> 20); }};template < typename PixTraits >class PixelAllocater {public: typedef PixTraits Traits; static typename Traits::ChannelType* allocate( unsigned long width, unsigned long height ) { return new typename Traits::ChannelType[ (height * width) * Traits::getTraitsImageType() ]; }};/**Defines a channel layout order of b,g,r,a withBitSizeType bits per channel*/template < typename BitSizeType, bool FloatingPoint=false, typename PixTraitsType=PixelTraits<BitSizeType,FloatingPoint>, typename PixAllocaterType=PixelAllocater<PixTraitsType> >struct BGRAPixel { typedef PixTraitsType Traits; typedef PixAllocaterType Allocater; enum { ChannelSize = Traits::ChannelSize }; BitSizeType b; BitSizeType g; BitSizeType r; BitSizeType a;};#ifndef __GNUC__/**floating point specialization*/template <>struct BGRAPixel<float, true > {#if defined(VCF_VC71) || defined(VCF_VC80) || defined(VCF_BCC) || defined(VCF_CW) typedef PixelTraits<float, true> Traits; typedef PixelAllocater<Traits> Allocater;#else typedef PixTraitsType Traits; typedef PixAllocaterType Allocater;#endif enum { ChannelSize = Traits::ChannelSize }; float b; float g; float r; float a;};#endif/**Defines a channel layout order of r,g,b,a withBitSizeType bits per channel*/template < typename BitSizeType, bool FloatingPoint=false, typename PixTraitsType=PixelTraits<BitSizeType,FloatingPoint>, typename PixAllocaterType=PixelAllocater<PixTraitsType> >struct RGBAPixel { typedef PixTraitsType Traits; typedef PixAllocaterType Allocater; enum { ChannelSize = Traits::ChannelSize }; BitSizeType r; BitSizeType g; BitSizeType b; BitSizeType a;};#ifndef __GNUC__/**floating point specialization*/template <>struct RGBAPixel<float, true > {#if defined(VCF_VC71) || defined(VCF_VC80) || defined(VCF_BCC) || defined(VCF_CW) typedef PixelTraits<float, true> Traits; typedef PixelAllocater<Traits> Allocater;#else typedef PixTraitsType Traits; typedef PixAllocaterType Allocater;#endif enum { ChannelSize = Traits::ChannelSize }; float r; float g; float b; float a;};#endif/**Defines a channel layout order of a,r,g,b withBitSizeType bits per channel*/template < typename BitSizeType, bool FloatingPoint=false, typename PixTraitsType=PixelTraits<BitSizeType,FloatingPoint>, typename PixAllocaterType=PixelAllocater<PixTraitsType> >struct ARGBPixel { typedef PixTraitsType Traits; typedef PixAllocaterType Allocater; enum { ChannelSize = Traits::ChannelSize }; BitSizeType a; BitSizeType r; BitSizeType g; BitSizeType b;};#ifndef __GNUC__/**floating point specialization*/template < >struct ARGBPixel<float, true > {#if defined(VCF_VC71) || defined(VCF_VC80) || defined(VCF_BCC) || defined(VCF_CW) typedef PixelTraits<float, true> Traits; typedef PixelAllocater<Traits> Allocater;#else typedef PixTraitsType Traits; typedef PixAllocaterType Allocater;#endif enum { ChannelSize = Traits::ChannelSize }; float a; float r; float g; float b;};#endif/**Defines a channel layout order of a,b,g,r withBitSizeType bits per channel*/template < typename BitSizeType, bool FloatingPoint=false, typename PixTraitsType=PixelTraits<BitSizeType,FloatingPoint>, typename PixAllocaterType=PixelAllocater<PixTraitsType> >struct ABGRPixel { typedef PixTraitsType Traits; typedef PixAllocaterType Allocater; enum { ChannelSize = Traits::ChannelSize }; BitSizeType a; BitSizeType b; BitSizeType g; BitSizeType r;};#ifndef __GNUC__/**floating point specialization*/template < >struct ABGRPixel<float,true> {#if defined(VCF_VC71) || defined(VCF_VC80) || defined(VCF_BCC) || defined(VCF_CW) typedef PixelTraits<float, true> Traits; typedef PixelAllocater<Traits> Allocater;#else typedef PixTraitsType Traits; typedef PixAllocaterType Allocater;#endif enum { ChannelSize = Traits::ChannelSize }; float a; float b; float g; float r;};#endif/**Defines a channel layout order of a,b,g,r withBitSizeType bits per channel*/template < typename BitSizeType, bool FloatingPoint=false,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?