www.pudn.com > terra-0_7.zip > Mask.cc


#include 
#include 
#include 

#include "Geom.h"
#include "Mask.h"


RealMask *readMask(istream& in)
{
    char magicP, magicNum;

    int width, height, maxval;

    in >> magicP >> magicNum;
    in >> width >> height >> maxval;

    if( magicP != 'P' )
    {
	cerr << "readMask: This is not PGM data." << endl;
	return NULL;
    }

    RealMask *mask = new RealMask(width, height);

    if( magicNum == '2' )
    {
	for(int j=0; j> val;
		mask->ref(i, j) = val;
	    }
    }
    else if( magicNum == '5' )
    {
	for(int j=0; j> val;
		mask->ref(i, j) = (real)val;
	    }
    }
    else
    {
	cerr << "readMask: This is not PGM data." << endl;
	return NULL;
    }


    real max = (real)maxval;

    for(int i=0; iref(i,j) /= max;

    return mask;
}