template<class ArrayT>
Definition at line 43 of file ReadPgm.h. References ILOG_DEBUG, ILOG_ERROR, ILOG_VAR, Impala::Util::IOBuffer::NativeTypeRead(), Impala::Util::IOBuffer::Read(), and SkipEmpty(). Referenced by ReadPgm(). 00044 { 00045 ILOG_VAR(Impala.Core.Array.ReadPgm); 00046 char c; 00047 bool IsAscii; 00048 int Width,Height,MaxVal; 00049 00050 00051 buffer->Read(&c,1); 00052 if(c!='P') 00053 { 00054 ILOG_ERROR("File is not in PGM format! Was waiting for P,but "<<c); 00055 return; 00056 } 00057 00058 buffer->Read(&c,1); 00059 if(c=='2') 00060 IsAscii=true; 00061 else if(c=='5') 00062 IsAscii=false; 00063 else 00064 { 00065 ILOG_ERROR("File is not in PGM format! "<<c); 00066 return; 00067 } 00068 SkipEmpty(buffer); 00069 00070 buffer->NativeTypeRead(&Width); 00071 buffer->NativeTypeRead(&Height); 00072 buffer->NativeTypeRead(&MaxVal); 00073 00074 ILOG_DEBUG("PGM Image with "<<Width<<"x"<<Height<<", maxval:"<<MaxVal); 00075 00076 00077 if(MaxVal>255){ 00078 ILOG_ERROR("MaxVal is greater than 255"); 00079 return; 00080 } 00081 00082 if (dst == 0) 00083 dst = ArrayCreate<ArrayT>(Width, Height); 00084 00085 if(IsAscii){ 00086 for(int k=0;k<Width;k++) 00087 { 00088 for(int l=0;l<Height;l++) 00089 { 00090 buffer->NativeTypeRead(&c); 00091 dst->SetValue(c,l,k); 00092 } 00093 } 00094 }else{ 00095 int read=buffer->Read(dst->PB(),Width*Height); 00096 if(read!=Width*Height){ 00097 ILOG_ERROR("Not Enough bytes could be read!"); 00098 return; 00099 } 00100 00101 } 00102 }
Here is the call graph for this function:
|