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

📄 imfxdr.h

📁 image converter source code
💻 H
📖 第 1 页 / 共 2 页
字号:
template <class S, class T>voidwrite (T &out, unsigned long v){    unsigned char b[8];    b[0] = (unsigned char) (v);    b[1] = (unsigned char) (v >> 8);    b[2] = (unsigned char) (v >> 16);    b[3] = (unsigned char) (v >> 24);    #if ULONG_MAX == 4294967295U	b[4] = 0;	b[5] = 0;	b[6] = 0;	b[7] = 0;    #elif ULONG_MAX == 18446744073709551615LU	b[4] = (unsigned char) (v >> 32);	b[5] = (unsigned char) (v >> 40);	b[6] = (unsigned char) (v >> 48);	b[7] = (unsigned char) (v >> 56);    #else		#error write<T> (T &out, unsigned long v) not implemented    #endif    writeUnsignedChars<S> (out, b, 8);}#if ULONG_MAX != 18446744073709551615LU    template <class S, class T>    void    write (T &out, Int64 v)    {        unsigned char b[8];        b[0] = (unsigned char) (v);        b[1] = (unsigned char) (v >> 8);        b[2] = (unsigned char) (v >> 16);        b[3] = (unsigned char) (v >> 24);        b[4] = (unsigned char) (v >> 32);        b[5] = (unsigned char) (v >> 40);        b[6] = (unsigned char) (v >> 48);        b[7] = (unsigned char) (v >> 56);        writeUnsignedChars<S> (out, b, 8);    }#endiftemplate <class S, class T>voidwrite (T &out, float v){    union {unsigned int i; float f;} u;    u.f = v;    unsigned char b[4];    b[0] = (unsigned char) (u.i);    b[1] = (unsigned char) (u.i >> 8);    b[2] = (unsigned char) (u.i >> 16);    b[3] = (unsigned char) (u.i >> 24);    writeUnsignedChars<S> (out, b, 4);}template <class S, class T>voidwrite (T &out, double v){    union {Int64 i; double d;} u;    u.d = v;    unsigned char b[8];    b[0] = (unsigned char) (u.i);    b[1] = (unsigned char) (u.i >> 8);    b[2] = (unsigned char) (u.i >> 16);    b[3] = (unsigned char) (u.i >> 24);    b[4] = (unsigned char) (u.i >> 32);    b[5] = (unsigned char) (u.i >> 40);    b[6] = (unsigned char) (u.i >> 48);    b[7] = (unsigned char) (u.i >> 56);    writeUnsignedChars<S> (out, b, 8);}template <class S, class T>inline voidwrite (T &out, half v){    unsigned char b[2];    b[0] =  (unsigned char) (v.bits());    b[1] =  (unsigned char) (v.bits() >> 8);    writeUnsignedChars<S> (out, b, 2);}template <class S, class T>inline voidwrite (T &out, const char v[], int n)	// fixed-size char array{    S::writeChars (out, v, n);}template <class S, class T>voidwrite (T &out, const char v[])		// zero-terminated string{    while (*v)    {	S::writeChars (out, v, 1);	++v;    }    S::writeChars (out, v, 1);}template <class S, class T>voidpad (T &out, int n)			// add n padding bytes{    for (int i = 0; i < n; i++)    {	const char c = 0;	S::writeChars (out, &c, 1);    }}template <class S, class T>inline voidread (T &in, bool &v){    char c;    S::readChars (in, &c, 1);    v = !!c;}template <class S, class T>inline voidread (T &in, char &v){    S::readChars (in, &v, 1);}template <class S, class T>inline voidread (T &in, signed char &v){    readSignedChars<S> (in, &v, 1);}template <class S, class T>inline voidread (T &in, unsigned char &v){    readUnsignedChars<S> (in, &v, 1);}template <class S, class T>voidread (T &in, signed short &v){    signed char b[2];    readSignedChars<S> (in, b, 2);    v = (b[0] & 0x00ff) |	(b[1] << 8);}template <class S, class T>voidread (T &in, unsigned short &v){    unsigned char b[2];    readUnsignedChars<S> (in, b, 2);    v = (b[0] & 0x00ff) |	(b[1] << 8);}template <class S, class T>voidread (T &in, signed int &v){    signed char b[4];    readSignedChars<S> (in, b, 4);    v =  (b[0]        & 0x000000ff) |	((b[1] << 8)  & 0x0000ff00) |	((b[2] << 16) & 0x00ff0000) |	 (b[3] << 24);}template <class S, class T>voidread (T &in, unsigned int &v){    unsigned char b[4];    readUnsignedChars<S> (in, b, 4);    v =  (b[0]        & 0x000000ff) |	((b[1] << 8)  & 0x0000ff00) |	((b[2] << 16) & 0x00ff0000) |	 (b[3] << 24);}template <class S, class T>voidread (T &in, signed long &v){    signed char b[8];    readSignedChars<S> (in, b, 8);    #if LONG_MAX == 2147483647	v =  (b[0]        & 0x000000ff) |	    ((b[1] << 8)  & 0x0000ff00) |	    ((b[2] << 16) & 0x00ff0000) |	     (b[3] << 24);	if (( b[4] ||  b[5] ||  b[6] ||  b[7]) &&	    (~b[4] || ~b[5] || ~b[6] || ~b[7]))	{	    throw Iex::OverflowExc ("Long int overflow - read a large "				    "64-bit integer in a 32-bit process.");	}    #elif LONG_MAX == 9223372036854775807L	v =  ((long) b[0]        & 0x00000000000000ff) |	    (((long) b[1] << 8)  & 0x000000000000ff00) |	    (((long) b[2] << 16) & 0x0000000000ff0000) |	    (((long) b[3] << 24) & 0x00000000ff000000) |	    (((long) b[4] << 32) & 0x000000ff00000000) |	    (((long) b[5] << 40) & 0x0000ff0000000000) |	    (((long) b[6] << 48) & 0x00ff000000000000) |	     ((long) b[7] << 56);    #else	#error read<T> (T &in, signed long &v) not implemented    #endif}template <class S, class T>voidread (T &in, unsigned long &v){    unsigned char b[8];    readUnsignedChars<S> (in, b, 8);    #if ULONG_MAX == 4294967295U	v =  (b[0]        & 0x000000ff) |	    ((b[1] << 8)  & 0x0000ff00) |	    ((b[2] << 16) & 0x00ff0000) |	     (b[3] << 24);	if (b[4] || b[5] || b[6] || b[7])	{	    throw Iex::OverflowExc ("Long int overflow - read a large "				    "64-bit integer in a 32-bit process.");	}    #elif ULONG_MAX == 18446744073709551615LU	v =  ((unsigned long) b[0]        & 0x00000000000000ff) |	    (((unsigned long) b[1] << 8)  & 0x000000000000ff00) |	    (((unsigned long) b[2] << 16) & 0x0000000000ff0000) |	    (((unsigned long) b[3] << 24) & 0x00000000ff000000) |	    (((unsigned long) b[4] << 32) & 0x000000ff00000000) |	    (((unsigned long) b[5] << 40) & 0x0000ff0000000000) |	    (((unsigned long) b[6] << 48) & 0x00ff000000000000) |	     ((unsigned long) b[7] << 56);    #else	#error read<T> (T &in, unsigned long &v) not implemented    #endif}#if ULONG_MAX != 18446744073709551615LU    template <class S, class T>    void    read (T &in, Int64 &v)    {        unsigned char b[8];        readUnsignedChars<S> (in, b, 8);        v =  ((Int64) b[0]        & 0x00000000000000ffLL) |	    (((Int64) b[1] << 8)  & 0x000000000000ff00LL) |	    (((Int64) b[2] << 16) & 0x0000000000ff0000LL) |	    (((Int64) b[3] << 24) & 0x00000000ff000000LL) |	    (((Int64) b[4] << 32) & 0x000000ff00000000LL) |	    (((Int64) b[5] << 40) & 0x0000ff0000000000LL) |	    (((Int64) b[6] << 48) & 0x00ff000000000000LL) |	    ((Int64) b[7] << 56);    }#endiftemplate <class S, class T>voidread (T &in, float &v){    unsigned char b[4];    readUnsignedChars<S> (in, b, 4);    union {unsigned int i; float f;} u;    u.i = (b[0]        & 0x000000ff) |	 ((b[1] << 8)  & 0x0000ff00) |	 ((b[2] << 16) & 0x00ff0000) |	  (b[3] << 24);    v = u.f;}template <class S, class T>voidread (T &in, double &v){    unsigned char b[8];    readUnsignedChars<S> (in, b, 8);    union {Int64 i; double d;} u;    u.i = ((Int64) b[0]        & 0x00000000000000ffULL) |	 (((Int64) b[1] << 8)  & 0x000000000000ff00ULL) |	 (((Int64) b[2] << 16) & 0x0000000000ff0000ULL) |	 (((Int64) b[3] << 24) & 0x00000000ff000000ULL) |	 (((Int64) b[4] << 32) & 0x000000ff00000000ULL) |	 (((Int64) b[5] << 40) & 0x0000ff0000000000ULL) |	 (((Int64) b[6] << 48) & 0x00ff000000000000ULL) |	  ((Int64) b[7] << 56);    v = u.d;}template <class S, class T>inline voidread (T &in, half &v){    unsigned char b[2];    readUnsignedChars<S> (in, b, 2);    v.setBits ((b[0] & 0x00ff) | (b[1] << 8));}template <class S, class T>inline voidread (T &in, char v[], int n)		// fixed-size char array{    S::readChars (in, v, n);}template <class S, class T>voidread (T &in, int n, char v[])		// zero-terminated string{    while (n >= 0)    {	S::readChars (in, v, 1);	if (*v == 0)	    break;	--n;	++v;    }}template <class S, class T>voidskip (T &in, int n)			// skip n padding bytes{    char c[1024];    while (n >= (int) sizeof (c))    {	if (!S::readChars (in, c, sizeof (c)))	    return;	n -= sizeof (c);    }    if (n >= 1)	S::readChars (in, c, n);}template <> inline int size <bool> ()			{return 1;}template <> inline int size <char> ()			{return 1;}template <> inline int size <signed char> ()		{return 1;}template <> inline int size <unsigned char> ()		{return 1;}template <> inline int size <signed short> ()		{return 2;}template <> inline int size <unsigned short> ()		{return 2;}template <> inline int size <signed int> ()		{return 4;}template <> inline int size <unsigned int> ()		{return 4;}template <> inline int size <signed long> ()		{return 8;}template <> inline int size <unsigned long> ()		{return 8;}template <> inline int size <float> ()			{return 4;}template <> inline int size <double> ()			{return 8;}template <> inline int size <half> ()			{return 2;}} // namespace Xdr} // namespace Imf#endif

⌨️ 快捷键说明

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