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