image_support/TGAlib

本文介绍了一个用于处理TGA图像文件的C++库,包括枚举定义、TGA图像结构体、加载图像头信息及像素数据的函数、灰度转换函数及释放内存的函数。该库提供了一系列实用功能,如读取文件状态、图像尺寸等。

#ifndef __SUPPORT_DATA_SUPPORT_TGALIB_H__

#define __SUPPORT_DATA_SUPPORT_TGALIB_H__


namespace cocos2d {


enum {

    TGA_OK,

    TGA_ERROR_FILE_OPEN,

    TGA_ERROR_READING_FILE,

    TGA_ERROR_INDEXED_COLOR,

    TGA_ERROR_MEMORY,

    TGA_ERROR_COMPRESSED_FILE,

};


/** TGA format */

typedef struct sImageTGA {

    int status;

    unsigned char type, pixelDepth;

    

    /** map width */

    signed short width;

    

    /** map height */

    signed short height;

    

    /** raw data */

    unsigned char *imageData;

    int flipped;

} tImageTGA;


/// load the image header fields. We only keep those that matter!

bool tgaLoadHeader(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psInfo);


/// loads the image pixels. You shouldn't call this function directly

bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psInfo);


/// this is the function to call when we want to load an image

tImageTGA * tgaLoad(const char *pszFilename);


// /converts RGB to grayscale

void tgaRGBtogreyscale(tImageTGA *psInfo);


/// releases the memory used for the image

void tgaDestroy(tImageTGA *psInfo);


}//namespace cocos2d 


#endif // __SUPPORT_DATA_SUPPORT_TGALIB_H__


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值