#include #include /* * THEAD takes a CVL picture header and checks it for consistency and * completeness. If all is fine, 0 is returned. If some things are * odd, but can be fixed as stated in the cvl header description, * 1 is returned. If it can not be fixed, -1 is returned. * If flag is true, error messages will be printed to stderr * when -1 is returned. * Only the following fields are checked: * bits-per-pixel * bands-per-pixel * sigbits-per-band * sigbits-per-pixel * bits-per-band * * Andrew Jewell 1/4/87 cc -O -c thead.c */ int thead (area, flag) struct cvl_p *area; int flag; { int returnflag = 0; if (area->cv_bp <= 0) { if (flag) fprintf(stderr,"Bits per pixel <= 0\n"); return(-1); } if (area->cv_sbp == 0) { if (area->cv_sbb == 0) { area->cv_sbb = area->cv_bb; returnflag = 1; } area->cv_sbp = area->cv_bp; returnflag = 1; } if ((area->cv_bnds * area->cv_bb) > area->cv_bp) { if (flag) fprintf(stderr,"bands*bits-per-band exceeds bits-per-pixel\n"); return(-1); } if ((area->cv_bnds * area->cv_bb) > area->cv_sbp) { area->cv_sbp = area->cv_bb * area->cv_bnds; returnflag = 1; } if (area->cv_bp < area->cv_sbp) { area->cv_sbp = area->cv_bp; returnflag = 1; } if (area->cv_bb < area->cv_sbb) { area->cv_sbb = area->cv_bb; returnflag = 1; } return(returnflag); }