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


C++ Pixel::SetInput方法代码示例

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


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

示例1: UpdateTexture

/**	Updates the texture
 *
 *	@returns	The texture buffer ID of this object
 *
 *	Operation:
 *		-#	Attempts to use the vfs to open the file
 *		-#	Sets the filename to the file requested
 *		-#	If the file handle is valid, continue to load the image
 *		-#	Read the file contents
 *		-#	Close the file handle
 *		-#	Create a 32bit image buffer to store the image in
 *		-#	Create two pixel objects, src/dest, the dest pixel object is 32bit, the src is whatever bpp the source image was
 *		-#	Setup the pixel objects to read pixels from the src image and convert them to 32bit pixels
 *		-#	Loop through the pixels, converting each to 32bit
 *		-#	delete any temporary memory allocated
 *		-#	Return the texture buffer id
 */
int OGLImageTexture::UpdateTexture(void)
{
	DeleteTexture();

	VFSHandle *handle = fusion->vfs->Open(m_filename);

	if(handle != NULL){
		SetFilename(handle->Filename());

		m_fileinfo = reinterpret_cast<ImageFileInfo *>(handle->Read());

		if(m_fileinfo != NULL){
			m_width		=	m_fileinfo->width;
			m_height	=	m_fileinfo->height;
			m_numcomp	=	m_fileinfo->bpp>>3;

			unsigned char *buffer = m_fileinfo->data;

			if(m_fileinfo->bpp < 24){
				m_numcomp = 3;

				buffer = new unsigned char[m_width * m_height * m_numcomp];

				Pixel	*s = NULL;
				Pixel	*d = new Pixel24Bit(buffer);

				switch(m_fileinfo->bpp){
					case 8:	{ s = new Pixel8Bit	(m_fileinfo->data,m_fileinfo->palette);	}break;
					case 16:{ s = new Pixel16Bit(m_fileinfo->data,5,6,5);				}break;
				};

				d->SetInput(s->GetOutput());

				int numpixels = m_width * m_height;

				for(int offset=0;offset<numpixels;offset++){
					s->ReadPixel(offset);
					d->WritePixel(offset);
				}

				delete		s;
				delete		d;
				delete[]	m_fileinfo->data;
			}

			CreateTexture(buffer);

			delete[]	buffer;
			delete[]	m_fileinfo->palette;
			delete		m_fileinfo;
		}	
开发者ID:christhomas,项目名称:fusionengine,代码行数:68,代码来源:OGLImageTexture.cpp


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