diff --git a/CMakeLists.txt b/CMakeLists.txt index c296081..947f723 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,3 +2,4 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(TexC) ADD_SUBDIRECTORY(BPTCEncoder) +ADD_SUBDIRECTORY(IO) diff --git a/IO/CMakeLists.txt b/IO/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/IO/ImageFile.cpp b/IO/ImageFile.cpp index e60625d..fd26238 100644 --- a/IO/ImageFile.cpp +++ b/IO/ImageFile.cpp @@ -1,28 +1,48 @@ #include "ImageFile.h" +ImageFile::ImageFile(const char *filename) : + m_PixelData(0) +{ + unsigned char *rawData = ReadFileData(filename); + DetectFileFormat(filename); + LoadImage(rawData); + delete [] rawData; +} + +ImageFile::ImageFile(const char *filename, EImageFileFormat format) : + m_FileFormat(format), + m_PixelData(0) +{ + unsigned char *rawData = ReadFileData(filename); + LoadImage(rawData); + delete [] rawData; +} + +ImageFile::~ImageFile() { + if(m_PixelData) { + delete [] m_PixelData; + } +} + +void ImageFile::GetPixels() const { + +} + +EImageFileFormat ImageFile::DetectFileFormat() { +} + +void ImageFile::LoadImage(const unsigend char *rawImageData) { +} + +void ImageFile::LoadPNGImage(const unsigned char *rawImageData) { +} + #ifdef _MSC_VER -ImageFile::ImageFile(const char *filename) { -} - -ImageFile::~ImageFile() { -} - -void ImageFile::GetPixels() const { +unsigned char *ImageFile::ReadFileData(const char *filename) { } - #else -#include - -ImageFile::ImageFile(const char *filename) { -} - -ImageFile::~ImageFile() { -} - -void ImageFile::GetPixels() const { +unsigned char *ImageFile::ReadFileData(const char *filename) { } - #endif - diff --git a/IO/ImageFile.h b/IO/ImageFile.h index a510389..f01f879 100644 --- a/IO/ImageFile.h +++ b/IO/ImageFile.h @@ -1,21 +1,36 @@ #ifedef _IMAGE_FILE_H_ #define _IMAGE_FILE_H_ +enum EImageFileFormat { + eFileFormat_PNG, + + kNumImageFileFormats +}; + class ImageFile { public: ImageFile(const char *filename); + ImageFile(const char *filename, EImageFileFormat format); ~ImageFile(); void GetWidth() const { return m_Width; } void GetHeight() const { return m_Height; } - void GetPixels() const; + const unsigned char *GetPixels() const { return m_PixelData; } private: unsigned int m_Handle; unsigned int m_Width; unsigned int m_Height; + unsigned char *m_PixelData; + const EImageFileFormat m_FileFormat; + + static unsigned char *ReadFileData(const char *filename); + static EFileFormat DetectFileFormat(const char *filename); + + bool LoadImage(const unsigned char *rawImageData); + bool LoadPNGImage(const unsigned char *rawImageData); };