📄 texture.h
字号:
/*
* read_texture() - read in an image file in SGI 'libimage' format
* currently its very simple minded and converts all images
* to RGBA8 regardless of the input format and returns the
* original number of components in the appropriate parameter.
*
* 常规的.rgb文件结构是:
* 前面12字节是有关总体信息
* 除前512字节外,后面的字节是
* rrr ... ...
* ggg ... ...
* bbb ... ...
* aaa ... ...
*
* the components are converted as follows
* L -> LLL 1.0
* LA -> LLL A
* RGB -> RGB 1.0
* RGBA -> RGB A
*
*/
#ifndef _TEXTURE_
#define _TEXTURE_
typedef struct _ImageRec {
unsigned short imagic;
unsigned short type;
unsigned short dim;
unsigned short xsize, ysize, zsize;
unsigned int min, max;
unsigned int wasteBytes;
char name[80];
unsigned long colorMap;
FILE *file;
unsigned char *tmp;
unsigned long rleEnd;
unsigned int *rowStart;
int *rowSize;
} ImageRec;
class CTexture
{
public:
CTexture();
~CTexture();
protected:
unsigned char*base;
unsigned char *rbuf, *gbuf, *bbuf, *abuf;
ImageRec *image;
public:
unsigned char*read_texture(char *name, int *width, int *height, int *components);
protected:
void bwtorgba(unsigned char *b,unsigned char *l,int n);
void latorgba(unsigned char *b, unsigned char *a,unsigned char *l,int n);
void rgbtorgba(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n);
void rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n);
void rgbatorgba(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *a,unsigned char *l,int n);
void ConvertShort(unsigned short *array, long length);
void ConvertLong(unsigned *array, long length);
ImageRec *ImageOpen(const char *fileName);
void ImageClose();
void ImageGetRow(unsigned char *buf, int y, int z);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -