Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions EtcTool/EtcSourceImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ namespace Etc

}

// ----------------------------------------------------------------------------------------------------
// Flip the image in Y
void SourceImage::FlipY(void)
{
const size_t rowSizeBytes = sizeof(ColorFloatRGBA) * m_uiWidth;
char *pacRow = new char[rowSizeBytes];
assert(pacRow);

for (int iY = 0; iY < m_uiHeight / 2; ++iY)
{
ColorFloatRGBA *row1 = m_pafrgbaPixels + m_uiWidth * iY;
ColorFloatRGBA *row2 = m_pafrgbaPixels + m_uiWidth * (m_uiHeight - 1 - iY);
memcpy(pacRow, row1, rowSizeBytes);
memcpy(row1, row2, rowSizeBytes);
memcpy(row2, pacRow, rowSizeBytes);
}

delete [] pacRow;
}

// ----------------------------------------------------------------------------------------------------
//

Expand Down
1 change: 1 addition & 0 deletions EtcTool/EtcSourceImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Etc
void SetName(const char *a_pstrFilename);

void NormalizeXYZ(void);
void FlipY(void);

inline const char *GetFilename(void)
{
Expand Down
12 changes: 12 additions & 0 deletions EtcTool/EtcTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Commands
i_vPixel = -1;
verboseOutput = false;
boolNormalizeXYZ = false;
boolFlipY = false;
mipmaps = 1;
mipFilterFlags = Etc::FILTER_WRAP_NONE;
}
Expand All @@ -114,6 +115,7 @@ class Commands
int i_hPixel;
int i_vPixel;
bool boolNormalizeXYZ;
bool boolFlipY;
int mipmaps;
unsigned int mipFilterFlags;
};
Expand Down Expand Up @@ -152,6 +154,10 @@ int main(int argc, const char * argv[])
{
sourceimage.NormalizeXYZ();
}
if (commands.boolFlipY)
{
sourceimage.FlipY();
}

unsigned int uiSourceWidth = sourceimage.GetWidth();
unsigned int uiSourceHeight = sourceimage.GetHeight();
Expand Down Expand Up @@ -628,6 +634,11 @@ bool Commands::ProcessCommandLineArguments(int a_iArgs, const char *a_apstrArgs[
{
boolNormalizeXYZ = true;
}
else if (strcmp(a_apstrArgs[iArg], "-flipy") == 0 ||
strcmp(a_apstrArgs[iArg], "-flipY") == 0)
{
boolFlipY = true;
}
else if (strcmp(a_apstrArgs[iArg], "-output") == 0)
{
++iArg;
Expand Down Expand Up @@ -800,6 +811,7 @@ void Commands::PrintUsageMessage(void)
printf(" -help prints this message\n");
printf(" -jobs or -j <thread_count> specifies the number of threads (default=1)\n");
printf(" -normalizexyz normalize RGB to have a length of 1\n");
printf(" -flipy flip the image vertically\n");
printf(" -verbose or -v shows status information during the encoding\n");
printf(" process\n");
printf(" -mipmaps or -m <mip_count> sets the maximum number of mipaps to generate (default=1)\n");
Expand Down