当前位置: 首页>>代码示例>>C++>>正文


C++ Asset::Read方法代码示例

本文整理汇总了C++中Asset::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ Asset::Read方法的具体用法?C++ Asset::Read怎么用?C++ Asset::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Asset的用法示例。


在下文中一共展示了Asset::Read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestAsset

bool ImageFormat_TGA::TestAsset(const Asset& asset)
	{
	// Check if the footer says that this is a TGA file
	if (asset.Open())
		{
		asset.Seek(-18,Asset::SEEK_FROM_END);
		char buffer[16];
		asset.Read(buffer,16);
		asset.Close();
		if (StrNCmp(buffer,"TRUEVISION-XFILE",16)==0)
			{
			return true;
			}
		}

	// If the footer doesn't match, this might still be a tga file (version < 2)
	// so try and load it as a tga and see if it works...
	int size=asset.GetSize();
	char* buffer=new char[size];
	asset.Open();
	asset.Read(buffer,size);
    asset.Close();

	tga_image image;
	tga_read_from_Buffer(&image,buffer);

	delete[] buffer;

	// Check to see if the header data makes sense...
	if (image.width<32767 && image.height<32767 && image.image_data && (image.pixel_depth==8 || image.pixel_depth==24 || image.pixel_depth==16 || image.pixel_depth==32))
		{
		// Yeah, sure, this looks like proper data, so give thumbs up and hope for the best
		return true;
		}

	tga_free_buffers(&image);

	// Nope, not likely to be a TGA
	return false;
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:40,代码来源:ImageFormat_TGA.cpp

示例2:

ImageFormat_TGA::ImageFormat_TGA(const Asset& asset):
	image_(0)
	{
	int size=asset.GetSize();
	char* buffer=new char[size];
	asset.Open();
	asset.Read(buffer,size);
    asset.Close();

	image_=new tga_image;
	tga_read_from_Buffer(static_cast<tga_image*>(image_),buffer);

	delete[] buffer;
    }
开发者ID:RichardMarks,项目名称:Pixie,代码行数:14,代码来源:ImageFormat_TGA.cpp

示例3: TestAsset

bool AudioFormat_YM::TestAsset(const Asset& asset)
	{
	if (asset.Open())
		{
		char buffer[7];
		asset.Read(buffer,7);
		asset.Close();
		if (StrNCmp(&buffer[2],"-lh5-",5)==0 || StrNCmp(buffer,"YM3!",4)==0)
			{
			return true;
			}
		}

	return false;
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:15,代码来源:AudioFormat_YM.cpp

示例4: TestAsset

bool ImageFormat_GIF::TestAsset(const Asset& asset)
	{
	if (asset.Open())
		{
		char buffer[3];
		asset.Read(buffer,3);
		asset.Close();
		if (StrNCmp(buffer,"GIF",3)==0)
			{
			return true;
			}
		}

	return false;
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:15,代码来源:ImageFormat_GIF.cpp

示例5: TestAsset

bool ImageFormat_PNG::TestAsset(const Asset& asset)
	{
	// Check if the header matches PNG files
	if (asset.Open())
		{
		unsigned char pngheader[]={137,80,78,71,13,10,26,10};
		unsigned char buffer[8];
		asset.Read(buffer,8);
		asset.Close();
		if (MemCmp(buffer,pngheader,8)==0)
			{
			return true;
			}
		}

	return false;
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:17,代码来源:ImageFormat_PNG.cpp

示例6: CYmMusic

AudioFormat_YM::AudioFormat_YM(const Asset& asset):
	ymFile_(0),
	chunkStart_(0),
	chunkEnd_(0)
	{
	if (asset.Open())
		{
		int size=asset.GetSize();
		unsigned char* buffer=static_cast<unsigned char*>(Malloc(size));
		asset.Read(buffer,size);
		asset.Close();

		ymFile_=new CYmMusic();
		ymFile_->loadMemory(buffer,size);
		ymFile_->setLoopMode(true);
		ymFile_->play();
		Free(buffer);
		}
	// Report missing file
	#ifdef _DEBUG
	else
		{
		const char* filename=asset.GetFilename().GetString();
		if (filename)
			{
			char errorMessage[1024];
			SNPrintF(errorMessage,1024,"File not found: %s",filename);
			Assert(false,errorMessage);
			}
		else
			{
			Assert(false,"An asset could not be accessed.");
			}
		}
	#endif
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:36,代码来源:AudioFormat_YM.cpp

示例7: if

void Bitmap_RLE8::Load(const Asset& asset)
	{
	if (asset.Open())
		{
		char header[8];
		asset.Read(header,8);

		if (StrNCmp(header,"PIXRLE8B",8)==0)
			{
			int version=0;
			asset.Read(&version);
			if (version==0)
				{
				int celCount=0;
				asset.Read(&celCount);
				if (celCount>=1)
					{
					ReadFromAsset(&asset);
					}
				}
			}

		else if (StrNCmp(header,"PIXIE_RL",8)==0)
			{
			char c;
			asset.Read(&c);
			int version=0;
			asset.Read(&version);
			if (version==0)
				{
				int celCount=0;
				asset.Read(&celCount);
				if (celCount>=1)
					{
					ReadFromAsset(&asset);
					}
				}
			}
		else
			{
			Assert(false,"Invalid RLE header");
			}
		}
	// Report missing file
	#ifdef _DEBUG
	else
		{
		const char* filename=asset.GetFilename().GetString();
		if (filename)
			{
			char errorMessage[1024];
			SNPrintF(errorMessage,1024,"File not found: %s",filename);
			Assert(false,errorMessage);
			}
		else
			{
			Assert(false,"An asset could not be accessed.");
			}
		}
	#endif
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:61,代码来源:Bitmap_RLE8.cpp


注:本文中的Asset::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。