Ejemplo n.º 1
0
Archivo: Blp.cpp Proyecto: hjhong/YDWE
//+-----------------------------------------------------------------------------
//| Reads BLP data
//+-----------------------------------------------------------------------------
bool BLP::Read(const BUFFER& SourceBuffer, BUFFER& TargetBuffer, int* Width, int* Height)
{
	BLP_HEADER Header;

	memcpy(reinterpret_cast<char*>(&Header), SourceBuffer.GetData(), sizeof(BLP_HEADER));
	if (Header.MagicNumber != '1PLB')
	{
		LOG("The file is not a BLP file!");
		return false;
	}

	switch(Header.Compression)
	{
	case 0:
		{
			if(!LoadCompressed(Header, SourceBuffer, TargetBuffer)) return false;
			break;
		}
	case 1:
		{
			if(!LoadUncompressed(Header, SourceBuffer, TargetBuffer)) return false;
			break;
		}
	default:
		{
			LOG("Unable to load  blp file, unknown compression method!");
			return false;
		}
	}

	if(Width != NULL) (*Width) = Header.Width;
	if(Height != NULL) (*Height) = Header.Height;

	return true;
}
Ejemplo n.º 2
0
//+-----------------------------------------------------------------------------
//| Loads a texture from a buffer
//+-----------------------------------------------------------------------------
BOOL TEXTURE_LOADER_BLP::Load(TEXTURE& Texture, CONST std::string& FileName, BUFFER& Buffer)
{
	BLP_HEADER Header;

	CurrentFileName = FileName;

	std::memcpy(reinterpret_cast<CHAR*>(&Header), &Buffer[0], sizeof(BLP_HEADER));
	if (Header.MagicNumber != '1PLB')
	{
		Error.SetMessage("The file is not a BLP texture!");
		return FALSE;
	}

	switch (Header.Compression)
	{
	case 0:
		{
			if (!LoadCompressed(Texture, Header, Buffer)) return FALSE;
			break;
		}
	case 1:
		{
			if (!LoadUncompressed(Texture, Header, Buffer)) return FALSE;
			break;
		}
	default:
		{
			Error.SetMessage("Unable to load \"" + FileName + "\", unknown compression method!");
			return FALSE;
		}

	}
	return TRUE;
}