bool cSkipHeaderBinaryFile::SetFilePos(int e_iPos) { if( m_pFile && m_iSkpiHeaderSize == 0 )//empty file do need to set position { //create header if(!CreateHeader()) return false; } int l_iSkipSize = GetSkipHeaderAndHMagicNumberHeader(); int ret = NvFSeek(m_pFile,e_iPos+l_iSkipSize,SEEK_SET); return ret==0?true:false; }
// loads 24-bit bmp files into 32-bit RGBA texture unsigned int *LoadBMP(char const *name, int *width, int *height) { NvFile *f = NvFOpen(name); if (f == 0) { LOGW("error opening %s!\n", name); return 0; } BITMAP_HEADER head; BMPV3_INFO_HEADER info; NvFRead(&head, sizeof(BITMAP_HEADER), 1, f); NvFRead(&info, sizeof(BMPV3_INFO_HEADER), 1, f); NvFSeek(f, head.bitmapPtr, SEEK_SET); *width = info.bWidth; *height = info.bHeight; uint *imageData = new uint[info.bWidth * info.bHeight]; int scanSize = (info.bWidth * (info.bBpp >> 3) + 3) & ~0x3; uchar *rdata = new uchar[scanSize]; for (int y = info.bHeight - 1; y >= 0; y--) { NvFRead(rdata, scanSize, 1, f); // shuffle rgb int index = y * info.bWidth; for (int i = 0; i < info.bWidth; i++) { imageData[index + i] = (rdata[i * 3] << 16) | (rdata[i * 3 + 1] << 8) | rdata[i * 3 + 2] | 0xff000000; } } NvFClose(f); delete[] rdata; LOGI("loaded %ix%i input image", info.bWidth, info.bHeight); return imageData; }
bool cBinaryFile::SetFilePos(int e_iPos) { return NvFSeek(m_pFile,e_iPos,SEEK_SET)==0?true:false; }
long MMfseek(MMFILE * stream, long offset, int type) { return NvFSeek((NvFile*)stream, offset, type); }