core/vil/file_formats/vil_bmp_core_header.cxx
Go to the documentation of this file.
00001 // This is core/vil/file_formats/vil_bmp_core_header.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author fsm
00008 
00009 #include "vil_bmp_core_header.h"
00010 
00011 #include <vcl_iostream.h>
00012 
00013 #include <vil/vil_stream.h>
00014 #include <vil/vil_stream_read.h>
00015 #include <vil/vil_stream_write.h>
00016 
00017 vil_bmp_core_header::vil_bmp_core_header()
00018 {
00019   header_size = disk_size;
00020   width = 0;
00021   height = 0;
00022   planes = 1;
00023   bitsperpixel = 8;
00024 }
00025 
00026 void vil_bmp_core_header::read(vil_stream *s)
00027 {
00028   header_size  = vil_stream_read_little_endian_uint_32(s);
00029   width        = vil_stream_read_little_endian_uint_32(s);
00030   height       = vil_stream_read_little_endian_uint_32(s);
00031   planes       = vil_stream_read_little_endian_uint_16(s);
00032   bitsperpixel = vil_stream_read_little_endian_uint_16(s);
00033   // allowed values for bitsperpixel are 1 4 8 16 24 32; currently we only support 8 and 24
00034 }
00035 
00036 void vil_bmp_core_header::write(vil_stream *s) const
00037 {
00038   vil_stream_write_little_endian_uint_32(s, header_size);
00039   vil_stream_write_little_endian_uint_32(s, width);
00040   vil_stream_write_little_endian_uint_32(s, height);
00041   vil_stream_write_little_endian_uint_16(s, planes);
00042   vil_stream_write_little_endian_uint_16(s, bitsperpixel);
00043 }
00044 
00045 void vil_bmp_core_header::print(vcl_ostream &s) const
00046 {
00047   s << "vil_bmp_core_header:\n"
00048     << "  header_size  : " << header_size  << vcl_endl
00049     << "  width        : " << width        << vcl_endl
00050     << "  height       : " << height       << vcl_endl
00051     << "  planes       : " << planes       << vcl_endl
00052     << "  bitsperpixel : " << bitsperpixel << vcl_endl << vcl_endl;
00053 }