vil_sgi_file_header.cxx
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_sgi_file_header.cxx
2 //:
3 // \file
4 // \author David Hughes
5 
6 #include <iomanip>
7 #include <iostream>
8 
9 #include "vil_sgi_file_header.h"
10 #include <vil/vil_stream.h>
11 #include <vil/vil_stream_write.h>
12 #include <vil/vil_stream_read.h>
13 
14 // The magic number for SGI images
15 #define SGI_SIGNATURE_BYTE_0 0x01
16 #define SGI_SIGNATURE_BYTE_1 0xDA
17 
19 {
20 
21  // Fill in all the numberical fields
22  // Don't worry about the dummy values or image name, which are ignored
25  storage = 0;
26  bpc = 1;
27  dimension = 0;
28  xsize = 0;
29  ysize = 0;
30  zsize = 0;
31  pixmin = 0;
32  pixmax = 255;
33  colormap = 0;
34 }
35 
36 void vil_sgi_file_header::print(std::ostream &s) const
37 {
38  s << "vil_sgi_file_header:\n"
39  << " magic : " << std::hex
40  << "0x" << unsigned(magic[0]) << ' '
41  << "0x" << unsigned(magic[1]) << std::dec << std::endl
42  << " storage : " << storage << std::endl
43  << " bpc : " << bpc << std::endl
44  << " dimension: " << dimension << std::endl
45  << " xsize : " << xsize << std::endl
46  << " ysize : " << ysize << std::endl
47  << " zsize : " << zsize << std::endl
48  << " pixmin : " << pixmin << std::endl
49  << " pixmax : " << pixmax << std::endl
50  << " colormap : " << colormap << std::endl << std::endl;
51 }
52 
54 {
55  if (s->read(&magic, sizeof(magic)) == 0) {magic[0] = magic[1] = 0;}
56  s->read(&storage, sizeof(storage));
57  s->read(&bpc, sizeof(bpc));
64  s->read(&dummy1, sizeof(dummy1));
65  s->read(&image_name, sizeof(image_name));
67  s->read(&dummy2, sizeof(dummy2));
68 }
69 
71 {
72  s->write(&magic, sizeof(magic));
73  s->write(&storage, sizeof(storage));
74  s->write(&bpc, sizeof(bpc));
81  s->write(&dummy1, sizeof(dummy1));
82  s->write(&image_name, sizeof(image_name));
84  s->write(&dummy2, sizeof(dummy2));
85 }
86 
88 {
89  return
92 }
Stream interface for VIL image loaders.
vxl_uint_32 vil_stream_read_big_endian_uint_32(vil_stream *s)
void write(vil_stream *) const
void print(std::ostream &) const
virtual vil_streampos write(void const *buf, vil_streampos n)=0
Write n bytes from buf. Returns number of bytes written.
read numbers from vil_stream
virtual vil_streampos read(void *buf, vil_streampos n)=0
Read n bytes into buf. Returns number of bytes read.
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
void vil_stream_write_big_endian_uint_32(vil_stream *s, vxl_uint_32 w)
void vil_stream_write_big_endian_uint_16(vil_stream *s, vxl_uint_16 w)
write integers to vil_stream
#define SGI_SIGNATURE_BYTE_0
void read(vil_stream *)
#define SGI_SIGNATURE_BYTE_1
unsigned char magic[2]
vxl_uint_16 vil_stream_read_big_endian_uint_16(vil_stream *s)