RMatrixX<T> readIPNG_T( const std::string & filename ) { std::ifstream is( filename.c_str(), std::fstream::in | std::fstream::binary ); if( !is.is_open() ) return RMatrixX<T>(); char magic[9]={0}; is.read( magic, 8 ); if ((std::string)magic != "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") printf("PNG bad magic!\n"); int W=0, H=0; while(!readHDR( is, W, H ) && !is.eof()); std::vector< T > data; std::vector< uint16_t > lbl_map; while(!is.eof() && is.is_open()){ if( lbl_map.size() == 0 ) lbl_map = readRemap( is ); std::vector<char> d = readDat( is ); if(d.size()) { RMatrixXu8 tmp = RMatrixXu8::Map( reinterpret_cast<uint8_t*>(d.data()), H, W+1 ).rightCols( W ); RMatrixX<T> r = tmp.cast<T>(); if (lbl_map.size()) { const int N = W*H; T * pr = r.data(); unsigned char * ptmp = tmp.data(); for( int i=0; i<N; i++ ) pr[i] = lbl_map[ ptmp[i] ]; } return r; } } return RMatrixX<T>(); }
RMatrixXus readPNG16(const std::string &filename) { std::ifstream is( filename.c_str(), std::fstream::in | std::fstream::binary ); if( !is.is_open() ) return RMatrixXus(); char magic[9]={0}; is.read( magic, 8 ); if ((std::string)magic != "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") printf("PNG bad magic!\n"); int W=0, H=0; while(!readHDR( is, W, H ) && !is.eof()); std::vector< short > data; while(!is.eof() && is.is_open()){ std::vector<char> r = readDat( is ); if(r.size()) { size_t o = data.size(); data.resize( o + W*H ); for( int i=0; i<H; i++ ) { uint16_t * pr = (uint16_t*)(r.data()+i*(W*sizeof(uint16_t)+1)+1); std::transform( pr, pr+W, data.begin()+o+i*W, htons2 ); } break; } } if( data.size() >= H*W ) { RMatrixXus r( H, W ); memcpy( r.data(), data.data(), W*H*sizeof(uint16_t) ); return r; } return RMatrixXus(); }
main() { int i; readDat(); jsValue(); writeDat(); for (i=0;i<cnt;i++) printf("b[%d]=%d\n",i,b[i]); }
void loadMaps(char *mapA, char *mapB, struct clonePos **retListA, struct clonePos **retListB, struct hash **retHashA, struct hash **retHashB) /* Load some maps. */ { char file[128], ext[64]; splitPath(mapA, NULL, file, ext); if (sameString(".dat", ext)) { readDat(mapA, retListA, retHashA, 0); readDat(mapA, retListB, retHashB, 1); } else { loadMap(mapA, retListA, retHashA); loadMap(mapB, retListB, retHashB); } }
main() { int i=0; readDat(); jsValue(); writeDat(); printf("cnt=%d\n满足条件的平均值pjz1=%7.2lf\n不满足条件的平均值pjz2=%7.2lf\n", cnt,pjz1,pjz2); }
alt_32 update(void *context) { int i; for (i = 0; i < 4; i++) prev_state[i] = button_states[i]; for (i = 0; i < 4; i++) button_states[i] = getButton(i); readDat(); runState(); return 1; }
void main() { int i ; readDat() ; jsVal() ; printf("满足条件的数=%d\n", cnt) ; for(i = 0 ; i < cnt ; i++) printf("%d ", b[i]) ; printf("\n") ; writeDat() ; }
std::vector<RMatrixXu8> readAPNG( const std::string & filename ) { std::ifstream is( filename.c_str(), std::fstream::in | std::fstream::binary ); if( !is.is_open() ) return std::vector<RMatrixXu8>(); char magic[9]={0}; is.read( magic, 8 ); if ((std::string)magic != "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") printf("PNG bad magic!\n"); int W=0, H=0; while(!readHDR( is, W, H ) && !is.eof()); std::vector<RMatrixXu8> r; while(!is.eof() && is.is_open()){ std::vector<char> d = readDat( is ); if(d.size()) r.push_back( RMatrixXu8::Map( reinterpret_cast<uint8_t*>(d.data()), H, W+1 ).rightCols( W ) ); } return r; }