13   Image(
void* 
const data, 
int w, 
int h, 
int channels, 
size_t component_size = 
sizeof(uint8_t));
    14   Image(
int w, 
int h, 
int channels, 
size_t component_size = 
sizeof(uint8_t));
    15   virtual ~
Image() {_free_image_data();}
    16   virtual void _free_image_data(){
    22   int getWidth()
 const {
return(width);}
    23   int getHeight()
 const {
return(height);}
    24   int getChannels()
 const {
return(channels);}
    25   size_t getComponentSize()
 const {
return(component_size);}
    26   size_t getTotalDataSize()
 const {
return(component_size*channels*width*height);}
    28   enum class ImageWriteFormat {PNG,HDR,JPEG};
    30   int writeFile(
const string& path) 
const;
    31   int writeFile(
const char* path)
 const {
return(writeFile(
string(path)));}
    32   int writeFileFormat(
const string& path, ImageWriteFormat format) 
const;
    33   int writeFileFormat(
const char* path, ImageWriteFormat format)
 const {
return(writeFileFormat(
string(path), format));}
    35   uint8_t* data = 
nullptr;
    41   size_t component_size;
    46     ExternalImage(
const string& path, 
bool delay_load = 
false, 
int expected_channels=-1);
    50   virtual void _free_image_data();
    52   bool load(
int expected_channels=-1) {
    53     if(loaded){fprintf(stderr, 
"Warning! Tried to load already loaded image.\n"); 
return(
false);}
    54     else{
return(pload(expected_channels));}
    57   const string& getPath()
 const {
return(path);}
    58   const bool isLoaded()
 const {
return(loaded);}
    60   const char* 
const getErrorMsg()
 const {
if(stb_fail_reason){
return(stb_fail_reason);} 
else {
return(
nullptr);}}
    61   virtual void printErrorMsg()
 const {
if(stb_fail_reason){fprintf(stderr, 
"Image load failed: '%s'\n", stb_fail_reason);}}
    63   virtual bool pload(
int expected_channels);
    66   const char* stb_fail_reason = 
nullptr;
    71   ExternalImageHDR(
string path, 
bool delay_load = 
false, 
int expected_channels=-1);
    72     ExternalImageHDR(
const char* 
const path, 
bool delay_load = 
false, 
int expected_channels=-1);
    73   void printErrorMsg()
 const override {
if(stb_fail_reason){fprintf(stderr, 
"HDR Image load failed: '%s'\n", stb_fail_reason);}}
    75   bool pload(
int expected_channels) 
override;