vil_stream_write.cxx
Go to the documentation of this file.
1 //:
2 // \file
3 // \author fsm
4 //
5 // \verbatim
6 // Modifications
7 // 23 Oct.2003 - Peter Vanroose - Added support for 64-bit int pixels
8 // \endverbatim
9 
10 #include "vil_stream_write.h"
11 #include <vil/vil_stream.h>
12 #include <vxl_config.h>
13 
15 {
16  vxl_uint_8 bytes[2];
17  bytes[0] = vxl_uint_8(w >> 8);
18  bytes[1] = vxl_uint_8(w & 0xff);
19  s->write(bytes, sizeof bytes);
20 }
21 
23 {
24  vxl_uint_8 bytes[2];
25  bytes[0] = vxl_uint_8(w & 0xff);
26  bytes[1] = vxl_uint_8(w >> 8);
27  s->write(bytes, sizeof bytes);
28 }
29 
31 {
32  vxl_byte bytes[4];
33  bytes[0] = w >> 24;
34  bytes[1] = w >> 16;
35  bytes[2] = w >> 8;
36  bytes[3] = w >> 0;
37  s->write(bytes, sizeof bytes);
38 }
39 
41 {
42  vxl_byte bytes[4];
43  bytes[0] = w >> 0;
44  bytes[1] = w >> 8;
45  bytes[2] = w >> 16;
46  bytes[3] = w >> 24;
47  s->write(bytes, sizeof bytes);
48 }
49 
51 {
52  vxl_byte bytes[4];
53  bytes[0] = w >> 24;
54  bytes[1] = w >> 16;
55  bytes[2] = w >> 8;
56  bytes[3] = w >> 0;
57  s->write(bytes, sizeof bytes);
58 }
59 
61 {
62  vxl_byte bytes[4];
63  bytes[0] = w >> 0;
64  bytes[1] = w >> 8;
65  bytes[2] = w >> 16;
66  bytes[3] = w >> 24;
67  s->write(bytes, sizeof bytes);
68 }
69 
70 #if VXL_HAS_INT_64
71 
72 void vil_stream_write_big_endian_uint_64(vil_stream *s, vxl_uint_64 w)
73 {
74  vxl_byte bytes[8];
75  bytes[0] = static_cast<vxl_byte>(w >> 56);
76  bytes[1] = static_cast<vxl_byte>(w >> 48);
77  bytes[2] = static_cast<vxl_byte>(w >> 40);
78  bytes[3] = static_cast<vxl_byte>(w >> 32);
79  bytes[4] = static_cast<vxl_byte>(w >> 24);
80  bytes[5] = static_cast<vxl_byte>(w >> 16);
81  bytes[6] = static_cast<vxl_byte>(w >> 8);
82  bytes[7] = static_cast<vxl_byte>(w >> 0);
83  s->write(bytes, sizeof bytes);
84 }
85 
86 void vil_stream_write_little_endian_uint_64(vil_stream *s, vxl_uint_64 w)
87 {
88  vxl_byte bytes[8];
89  bytes[0] = static_cast<vxl_byte>(w >> 0);
90  bytes[1] = static_cast<vxl_byte>(w >> 8);
91  bytes[2] = static_cast<vxl_byte>(w >> 16);
92  bytes[3] = static_cast<vxl_byte>(w >> 24);
93  bytes[4] = static_cast<vxl_byte>(w >> 32);
94  bytes[5] = static_cast<vxl_byte>(w >> 40);
95  bytes[6] = static_cast<vxl_byte>(w >> 48);
96  bytes[7] = static_cast<vxl_byte>(w >> 56);
97  s->write(bytes, sizeof bytes);
98 }
99 
100 #endif // VXL_HAS_INT_64
Stream interface for VIL image loaders.
void vil_stream_write_big_endian_int_32(vil_stream *, vxl_int_32)
void vil_stream_write_big_endian_uint_16(vil_stream *, vxl_uint_16)
virtual vil_streampos write(void const *buf, vil_streampos n)=0
Write n bytes from buf. Returns number of bytes written.
void vil_stream_write_little_endian_int_32(vil_stream *, vxl_int_32)
void vil_stream_write_little_endian_uint_16(vil_stream *, vxl_uint_16)
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
void vil_stream_write_big_endian_uint_32(vil_stream *, vxl_uint_32)
write integers to vil_stream
void vil_stream_write_little_endian_uint_32(vil_stream *, vxl_uint_32)