vil_bmp_file_header.cxx
Go to the documentation of this file.
1 // This is core/vil/file_formats/vil_bmp_file_header.cxx
2 //:
3 // \file
4 // \author fsm
5 
6 #include <iomanip>
7 #include <iostream>
8 #include "vil_bmp_file_header.h"
9 #ifdef _MSC_VER
10 # include <vcl_msvc_warnings.h>
11 #endif
12 #include <vil/vil_stream.h>
13 #include <vil/vil_stream_write.h>
14 #include <vil/vil_stream_read.h>
15 
16 // The signature consists of the two bytes 42, 4D in that order.
17 // It is not supposed to be read as a 16-bit integer.
18 #define BMP_SIGNATURE_BYTE_0 0x42
19 #define BMP_SIGNATURE_BYTE_1 0x4D
20 
22 {
25  file_size = 0;
26  reserved1 = 0;
27  reserved2 = 0;
28  bitmap_offset = 0;
29 }
30 
31 void vil_bmp_file_header::print(std::ostream &s) const
32 {
33  s << "vil_bmp_file_header:\n"
34  << " magic : " << std::hex
35  << "0x" << unsigned(magic[0]) << ' '
36  << "0x" << unsigned(magic[1]) << std::endl
37  << " filesize: 0x" << file_size << std::endl
38  << " reserved: 0x" << reserved1 << std::endl
39  << " reserved: 0x" << reserved2 << std::endl
40  << " offset : 0x" << bitmap_offset << std::endl
41  << std::dec << std::endl;
42 }
43 
45 {
46  if (s->read(&magic, sizeof(magic)) == 0) {magic[0] = magic[1] = 0;}
51 }
52 
54 {
55  s->write(&magic, sizeof(magic));
60 }
61 
63 {
64  return
67 }
Stream interface for VIL image loaders.
#define BMP_SIGNATURE_BYTE_0
void vil_stream_write_little_endian_uint_32(vil_stream *s, vxl_uint_32 w)
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.
void print(std::ostream &) const
void read(vil_stream *)
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
void write(vil_stream *) const
write integers to vil_stream
void vil_stream_write_little_endian_uint_16(vil_stream *s, vxl_uint_16 w)
#define BMP_SIGNATURE_BYTE_1
vxl_uint_32 vil_stream_read_little_endian_uint_32(vil_stream *s)
vxl_uint_16 vil_stream_read_little_endian_uint_16(vil_stream *s)