2012-08-26 23:05:18 +00:00
|
|
|
#ifndef _IMAGE_FILE_H_
|
2012-08-26 18:46:47 +00:00
|
|
|
#define _IMAGE_FILE_H_
|
|
|
|
|
2012-10-03 23:58:33 +00:00
|
|
|
#include "TexCompTypes.h"
|
2012-08-28 02:47:20 +00:00
|
|
|
#include "ImageFileFormat.h"
|
2012-08-26 20:37:10 +00:00
|
|
|
|
2012-09-21 16:39:09 +00:00
|
|
|
// Forward declare
|
2012-09-21 20:42:15 +00:00
|
|
|
class Image;
|
2012-09-21 16:39:09 +00:00
|
|
|
class CompressedImage;
|
2012-10-03 23:58:33 +00:00
|
|
|
struct SCompressionSettings;
|
2012-09-21 16:39:09 +00:00
|
|
|
|
|
|
|
// Class definition
|
2012-08-26 18:46:47 +00:00
|
|
|
class ImageFile {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ImageFile(const char *filename);
|
2012-08-26 20:37:10 +00:00
|
|
|
ImageFile(const char *filename, EImageFileFormat format);
|
2012-10-20 20:54:43 +00:00
|
|
|
ImageFile(const char *filename, EImageFileFormat format, const Image &);
|
2012-08-26 18:46:47 +00:00
|
|
|
~ImageFile();
|
|
|
|
|
2012-08-26 23:05:18 +00:00
|
|
|
unsigned int GetWidth() const { return m_Width; }
|
|
|
|
unsigned int GetHeight() const { return m_Height; }
|
2012-09-21 16:39:09 +00:00
|
|
|
CompressedImage *Compress(const SCompressionSettings &) const;
|
2012-09-21 20:42:15 +00:00
|
|
|
Image *GetImage() const { return m_Image; }
|
2012-08-26 18:46:47 +00:00
|
|
|
|
2012-10-20 20:54:43 +00:00
|
|
|
bool Load();
|
|
|
|
bool Write();
|
|
|
|
|
2012-08-26 18:46:47 +00:00
|
|
|
private:
|
2012-10-20 20:54:43 +00:00
|
|
|
static const unsigned int kMaxFilenameSz = 256;
|
|
|
|
char m_Filename[kMaxFilenameSz];
|
2012-08-26 18:46:47 +00:00
|
|
|
unsigned int m_Handle;
|
|
|
|
unsigned int m_Width;
|
|
|
|
unsigned int m_Height;
|
2012-09-21 20:42:15 +00:00
|
|
|
|
|
|
|
Image *m_Image;
|
|
|
|
|
2012-08-26 20:37:10 +00:00
|
|
|
const EImageFileFormat m_FileFormat;
|
|
|
|
|
2012-10-03 23:58:33 +00:00
|
|
|
static unsigned char *ReadFileData(const CHAR *filename);
|
2012-10-20 23:01:07 +00:00
|
|
|
static bool WriteImageDataToFile(const uint8 *data, const uint32 dataSz, const CHAR *filename);
|
2012-10-03 23:58:33 +00:00
|
|
|
static EImageFileFormat DetectFileFormat(const CHAR *filename);
|
2012-08-26 20:37:10 +00:00
|
|
|
|
2012-09-21 20:42:15 +00:00
|
|
|
Image *LoadImage(const unsigned char *rawImageData) const;
|
2012-08-26 18:46:47 +00:00
|
|
|
};
|
|
|
|
#endif // _IMAGE_FILE_H_
|