template<class ArrayT>
Definition at line 146 of file ReadImage.h. References cImageTypeJpg, cImageTypePng, Impala::FileNameExt(), Impala::Persistency::File::GetPath(), Impala::Persistency::File::GetReadBuffer(), ILOG_ERROR, ILOG_VAR, ILOG_WARN, Impala::Util::IOBuffer::Read(), ReadImageIdentity(), ReadJpgFromMemory(), ReadPngFromMemory(), and Impala::Util::IOBuffer::Size(). Referenced by ReadFile(). 00147 { 00148 ILOG_VAR(Impala.Core.Array.ReadImage); 00149 Util::IOBuffer* ioBuf = file.GetReadBuffer(); 00150 if (!ioBuf) 00151 return; 00152 00153 size_t bufSize = ioBuf->Size(); 00154 char* buf = new char[bufSize]; 00155 size_t nrRead = ioBuf->Read(buf, bufSize); 00156 if (nrRead != bufSize) 00157 { 00158 ILOG_ERROR("Buffer read failed"); 00159 delete buf; 00160 delete ioBuf; 00161 return; 00162 } 00163 00164 int imType = ReadImageIdentity(buf, bufSize); 00165 String nameExt = FileNameExt(file.GetPath(), true); 00166 if (imType == cImageTypePng) 00167 { 00168 if ((nameExt == "jpg") || (nameExt == "jpeg")) 00169 ILOG_WARN("File seems to contain a PNG instead of a JPG image"); 00170 ReadPngFromMemory(dst, buf, bufSize); 00171 } 00172 else if (imType == cImageTypeJpg) 00173 { 00174 if (nameExt == "png") 00175 ILOG_WARN("File seems to contain a JPG instead of a PNG image"); 00176 ReadJpgFromMemory(dst, buf, bufSize); 00177 } 00178 else 00179 { 00180 ILOG_ERROR("Don't understand " << file.GetPath()); 00181 } 00182 00183 delete buf; 00184 delete ioBuf; 00185 }
Here is the call graph for this function:
|