Skip to content

Commit 50c5020

Browse files
committed
ResourceEmbedder : Fix 8 bits output mode
1 parent eae4700 commit 50c5020

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ResourceEmbedder/ResourceEmbedder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
105105
fseek(pOriginFile, 0, SEEK_END);
106106
iOriginSize = (unsigned int)ftell(pOriginFile);
107107
fseek(pOriginFile, 0, SEEK_SET);
108-
char* pData = (char*)malloc(iOriginSize);
108+
unsigned char* pData = (unsigned char*)malloc(iOriginSize);
109109
fread(pData, 1, iOriginSize, pOriginFile);
110110

111111
fclose(pOriginFile);
@@ -122,7 +122,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
122122
if (iCompressBound > 0)
123123
{
124124
char* pCompressed = (char*)malloc(iCompressBound);
125-
iCompressedSize = (uint64_t)LZ4_compress_default(pData, pCompressed, (int)iOriginSize, iCompressBound);
125+
iCompressedSize = (uint64_t)LZ4_compress_default((const char*)pData, pCompressed, (int)iOriginSize, iCompressBound);
126126

127127
if (iCompressedSize >= iOriginSize)
128128
{
@@ -133,7 +133,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
133133
else
134134
{
135135
free(pData);
136-
pData = pCompressed;
136+
pData = (unsigned char*)pCompressed;
137137
}
138138
}
139139
}
@@ -143,7 +143,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
143143
if (iCompressBound > 0)
144144
{
145145
char* pCompressed = (char*)malloc(iCompressBound);
146-
iCompressedSize = (uint64_t)LZ4_compress_HC(pData, pCompressed, (int)iOriginSize, iCompressBound, 5);
146+
iCompressedSize = (uint64_t)LZ4_compress_HC((const char*)pData, pCompressed, (int)iOriginSize, iCompressBound, 5);
147147

148148
if (iCompressedSize >= iOriginSize)
149149
{
@@ -154,7 +154,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
154154
else
155155
{
156156
free(pData);
157-
pData = pCompressed;
157+
pData = (unsigned char*)pCompressed;
158158
}
159159
}
160160
}
@@ -175,7 +175,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
175175
else
176176
{
177177
free(pData);
178-
pData = pCompressed;
178+
pData = (unsigned char*)pCompressed;
179179
}
180180
}
181181
}
@@ -320,13 +320,13 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
320320
uint32_t iValue = 0;
321321
for (int iOffset = 0; iOffset < iStep && (iPos + iOffset) < iSize; ++iOffset)
322322
{
323-
if (eOutputMode == E_OUTPUT_MODE_32_BE)
323+
if (eOutputMode == E_OUTPUT_MODE_32_LE)
324324
{
325-
((unsigned char*)&iValue)[iOffset] = *(pData + iPos + iOffset);
325+
((unsigned char*)&iValue)[iOffset] = *(pData + iPos + (3 - iOffset));
326326
}
327327
else
328328
{
329-
((unsigned char*)&iValue)[iOffset] = *(pData + iPos + (3 - iOffset));
329+
((unsigned char*)&iValue)[iOffset] = *(pData + iPos + iOffset);
330330
}
331331
}
332332

0 commit comments

Comments
 (0)