Inverted Red and Blue channels for TGA loading
This commit is contained in:
parent
94bc1228f1
commit
01ad1a2317
2 changed files with 16 additions and 1 deletions
|
@ -71,7 +71,9 @@ bool Texture::load_tga(const std::string& filename, uint8_t*& data_array)
|
||||||
|
|
||||||
bool Texture::load_rgb_tga(const std::string& rgb_filename)
|
bool Texture::load_rgb_tga(const std::string& rgb_filename)
|
||||||
{
|
{
|
||||||
return load_tga(rgb_filename,image_data);
|
bool return_value = load_tga(rgb_filename,image_data);
|
||||||
|
invert_channels(0,2);
|
||||||
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Texture::load_rgba_tga(const std::string& rgb_filename, const std::string& mask_filename)
|
bool Texture::load_rgba_tga(const std::string& rgb_filename, const std::string& mask_filename)
|
||||||
|
@ -117,3 +119,14 @@ bool Texture::load_rgba_tga(const std::string& rgb_filename, const std::string&
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::invert_channels(uint8_t first_channel, uint8_t second_channel)
|
||||||
|
{
|
||||||
|
uint8_t increment = color_bits/8;
|
||||||
|
for (int i = 0;i<width*height;i++)
|
||||||
|
{
|
||||||
|
uint8_t temp = image_data[i*increment+first_channel];
|
||||||
|
image_data[i*increment+first_channel] = image_data[i*increment+second_channel];
|
||||||
|
image_data[i*increment+second_channel] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ public:
|
||||||
private:
|
private:
|
||||||
/// Load and RGB TGA image file to an array
|
/// Load and RGB TGA image file to an array
|
||||||
bool load_tga(const std::string& filename, uint8_t*& data_array);
|
bool load_tga(const std::string& filename, uint8_t*& data_array);
|
||||||
|
|
||||||
|
void invert_channels(uint8_t first_channel,uint8_t second_channel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue