Example #1
0
	void	cBinaryFile::CloseFile()
	{
		SAFE_DELETE(m_pData);
#ifdef WIN32
		if( m_FileHandle )
		{
			this->Flush();
			CloseHandle(m_FileHandle);
			m_FileHandle = 0;
		}
		else
		if( m_pFile )
		{
			this->Flush();
			fclose( m_pFile );
		}
#else
		if( m_pFile )
		{
			this->Flush();
			NvFClose( m_pFile );
		}
#endif
		m_pFile = 0;
	}
Example #2
0
// 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;
}
Example #3
0
void MMfclose(MMFILE * file)
{
    NvFClose((NvFile*)file);
}
void crClose(void* handle)
{
	NvFClose((NvFile*)handle);
}