core/vil/file_formats/vil_viffheader.cxx
Go to the documentation of this file.
00001 //:
00002 // \file
00003 #include "vil_viffheader.h"
00004 #include <string.h>
00005 
00006 
00007 //: Construct an image header
00008 // \param ncols - vil_image::ni()
00009 // \param nrows - vil_image::nj()
00010 // \param storage_type - similar to vil_image::pixel_format()
00011 // \param num_bands - similar to vil_image::n_planes()
00012 vil_viff_xvimage::vil_viff_xvimage(
00013   unsigned ncols, unsigned nrows,
00014   vil_viff_data_storage storage_type,
00015   unsigned num_bands)
00016 {
00017   const unsigned VIL_VIFF_COMMENT_LENGTH = 512L;
00018 
00019   identifier = (char)XV_FILE_MAGIC_NUM;
00020   file_type = XV_FILE_TYPE_XVIFF;
00021   release = XV_IMAGE_REL_NUM;
00022   version = XV_IMAGE_VER_NUM;
00023   machine_dep = VFF_DEP_IEEEORDER; /* assume IEEE byte order */
00024   memset(  reserve, 0, VIFF_HEADERSIZE-21*sizeof(vxl_sint_32)-520*sizeof(char)-4*sizeof(float));
00025   memset(  trash, 0, 3L);
00026   memset(  comment, 0, VIL_VIFF_COMMENT_LENGTH);
00027   strcpy(  comment, "vil_viff image writer output"); // This string needs to be shorter than 511 chars.
00028   row_size = ncols;
00029   col_size = nrows;
00030   subrow_size = 0; /* Don't care, just avoid uninitialised memory. */
00031   startx = VFF_NOTSUB;
00032   starty = VFF_NOTSUB;
00033   pixsizx = 1.0;
00034   pixsizy = 1.0;
00035   location_type = VFF_LOC_IMPLICIT;
00036   location_dim = 0;
00037   location = NULL;
00038   num_of_images = 1;
00039   num_data_bands = num_bands;
00040   data_storage_type = storage_type;
00041   data_encode_scheme = VFF_DES_RAW;
00042   map_scheme = VFF_MS_NONE;
00043   map_storage_type = VFF_MAPTYP_NONE;
00044   maps = NULL;
00045   map_row_size = 0;
00046   map_col_size = 0;
00047   map_subrow_size = 0;
00048   map_enable = VFF_MAP_OPTIONAL;
00049   maps_per_cycle = 0;      /* Don't care */
00050   color_space_model = VFF_CM_NONE;
00051   ispare1 = 0;
00052   ispare2 = 0;
00053   fspare1 = 0;
00054   fspare2 = 0;
00055 
00056   unsigned long image_data_n_bytes;
00057   switch (storage_type)
00058   {
00059     case VFF_TYP_BIT:       image_data_n_bytes = (ncols+7)/8; break;
00060     case VFF_TYP_2_BYTE:    image_data_n_bytes = ncols*2; break;
00061     case VFF_TYP_4_BYTE:
00062     case VFF_TYP_FLOAT:     image_data_n_bytes = ncols*4; break;
00063     case VFF_TYP_DOUBLE:
00064     case VFF_TYP_COMPLEX:   image_data_n_bytes = ncols*8; break;
00065     case VFF_TYP_DCOMPLEX:  image_data_n_bytes = ncols*16; break;
00066     default:                image_data_n_bytes = ncols*255; break;
00067   }
00068   image_data_n_bytes *= nrows*num_data_bands;
00069 
00070 
00071   imagedata = 0;
00072 }
00073 
00074 vil_viff_xvimage::vil_viff_xvimage()
00075 {
00076   memset(this,0, sizeof(vil_viff_xvimage));
00077 }
00078