Changeset View
Changeset View
Standalone View
Standalone View
source/lib/tex/tex_tga.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | Status TexCodecTga::decode(u8* RESTRICT data, size_t UNUSED(size), Tex* RESTRICT t) const | ||||
t->m_Width = w; | t->m_Width = w; | ||||
t->m_Height = h; | t->m_Height = h; | ||||
t->m_Bpp = bpp; | t->m_Bpp = bpp; | ||||
t->m_Flags = flags; | t->m_Flags = flags; | ||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
Status TexCodecTga::encode(Tex* RESTRICT t, DynArray* RESTRICT da) const | Status TexCodecTga::encode(Tex* RESTRICT t, DynArray* RESTRICT da, int quality) const | ||||
{ | { | ||||
u8 img_desc = 0; | u8 img_desc = 0; | ||||
if(t->m_Flags & TEX_TOP_DOWN) | if(t->m_Flags & TEX_TOP_DOWN) | ||||
img_desc |= TGA_TOP_DOWN; | img_desc |= TGA_TOP_DOWN; | ||||
if(t->m_Bpp == 32) | if(t->m_Bpp == 32) | ||||
img_desc |= 8; // size of alpha channel | img_desc |= 8; // size of alpha channel | ||||
TgaImgType img_type = (t->m_Flags & TEX_GREY)? TGA_GREY : TGA_TRUE_COLOR; | TgaImgType img_type = (t->m_Flags & TEX_GREY)? TGA_GREY : TGA_TRUE_COLOR; | ||||
Show All 20 Lines |
Wildfire Games · Phabricator