123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #pragma once
- #include "EtcColorFloatRGBA.h"
- #include "EtcImage.h"
- #include "Etc.h"
- namespace Etc
- {
- class FileHeader;
- class SourceImage;
- class File
- {
- public:
- enum class Format
- {
- INFER_FROM_FILE_EXTENSION,
- PKM,
- KTX,
- };
- File(const char *a_pstrFilename, Format a_fileformat, Image::Format a_imageformat,
- unsigned char *a_paucEncodingBits, unsigned int a_uiEncodingBitsBytes,
- unsigned int a_uiSourceWidth, unsigned int a_uiSourceHeight,
- unsigned int a_uiExtendedWidth, unsigned int a_uiExtendedHeight);
- File(const char *a_pstrFilename, Format a_fileformat, Image::Format a_imageformat,
- unsigned int a_uiNumMipmaps, RawImage *pMipmapImages,
- unsigned int a_uiSourceWidth, unsigned int a_uiSourceHeight );
- File(const char *a_pstrFilename, Format a_fileformat);
- ~File();
- const char *GetFilename(void) { return m_pstrFilename; }
- void Read(const char *a_pstrFilename);
- void Write(void);
- inline unsigned int GetSourceWidth(void)
- {
- return m_uiSourceWidth;
- }
- inline unsigned int GetSourceHeight(void)
- {
- return m_uiSourceHeight;
- }
- inline unsigned int GetExtendedWidth(unsigned int mipmapIndex = 0)
- {
- if (mipmapIndex < m_uiNumMipmaps)
- {
- return m_pMipmapImages[mipmapIndex].uiExtendedWidth;
- }
- else
- {
- return 0;
- }
- }
- inline unsigned int GetExtendedHeight(unsigned int mipmapIndex = 0)
- {
- if (mipmapIndex < m_uiNumMipmaps)
- {
- return m_pMipmapImages[mipmapIndex].uiExtendedHeight;
- }
- else
- {
- return 0;
- }
- }
- inline Image::Format GetImageFormat()
- {
- return m_imageformat;
- }
- inline unsigned int GetEncodingBitsBytes(unsigned int mipmapIndex = 0)
- {
- if (mipmapIndex < m_uiNumMipmaps)
- {
- return m_pMipmapImages[mipmapIndex].uiEncodingBitsBytes;
- }
- else
- {
- return 0;
- }
- }
- inline unsigned char* GetEncodingBits(unsigned int mipmapIndex = 0)
- {
- if( mipmapIndex < m_uiNumMipmaps)
- {
- return m_pMipmapImages[mipmapIndex].paucEncodingBits.get();
- }
- else
- {
- return nullptr;
- }
- }
- inline unsigned int GetNumMipmaps()
- {
- return m_uiNumMipmaps;
- }
- void UseSingleBlock(int a_iPixelX = -1, int a_iPixelY = -1);
- private:
- char *m_pstrFilename;
- Format m_fileformat;
- Image::Format m_imageformat;
- FileHeader *m_pheader;
- unsigned int m_uiNumMipmaps;
- RawImage* m_pMipmapImages;
- unsigned int m_uiSourceWidth;
- unsigned int m_uiSourceHeight;
- };
- }
|