MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / LoadUncompressedTGA

Method LoadUncompressedTGA

include/TGALoader/TGALoader.cpp:98–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96 }
97
98 void IMAGE::LoadUncompressedTGA (FILE* pFile)
99 {
100 unsigned char ucBuffer[4] = {255, 255, 255, 255};
101
102 unsigned int* pIntPointer = (unsigned int*) &m_Pixels[0];
103 unsigned int* pIntBuffer = (unsigned int*) &ucBuffer[0];
104
105 const int iPixelCount = m_iImageWidth * m_iImageHeight;
106
107 for (int i = 0; i < iPixelCount; ++i)
108 {
109 fread (ucBuffer, sizeof (unsigned char) * m_iBytesPerPixel, 1, pFile);
110
111 // if this is an 8-Bit TGA only, store the one channel in all four channels
112 // if it is a 24-Bit TGA (3 channels), the fourth channel stays at 255 all the time, since the 4th value in ucBuffer is never overwritten
113 if (m_iBytesPerPixel == 1)
114 {
115 ucBuffer[1] = ucBuffer[0];
116 ucBuffer[2] = ucBuffer[0];
117 ucBuffer[3] = ucBuffer[0];
118 }
119
120 // copy all four values in one operation
121 (*pIntPointer) = (*pIntBuffer);
122 ++pIntPointer;
123 }
124 }
125
126 void IMAGE::LoadCompressedTGA (FILE* pFile)
127 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected