|
|
|
|
@ -19,7 +19,7 @@ constexpr unsigned PcxPaletteSize = 1 + NumPaletteColors * 3;
|
|
|
|
|
bool LoadPcxMeta(HANDLE handle, int &width, int &height, std::uint8_t &bpp) |
|
|
|
|
{ |
|
|
|
|
PCXHeader pcxhdr; |
|
|
|
|
if (!SFileReadFile(handle, &pcxhdr, PcxHeaderSize, nullptr, nullptr)) { |
|
|
|
|
if (!SFileReadFileThreadSafe(handle, &pcxhdr, PcxHeaderSize)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
width = SDL_SwapLE16(pcxhdr.Xmax) - SDL_SwapLE16(pcxhdr.Xmin) + 1; |
|
|
|
|
@ -41,7 +41,7 @@ bool LoadPcxPixelsAndPalette(HANDLE handle, int width, int height, std::uint8_t
|
|
|
|
|
// We read 1 extra byte because it delimits the palette.
|
|
|
|
|
const unsigned readSize = pixelDataSize + (has256ColorPalette ? PcxPaletteSize : 0); |
|
|
|
|
std::unique_ptr<BYTE[]> fileBuffer { new BYTE[readSize] }; |
|
|
|
|
if (!SFileReadFile(handle, fileBuffer.get(), readSize, nullptr, nullptr)) { |
|
|
|
|
if (!SFileReadFileThreadSafe(handle, fileBuffer.get(), readSize)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
const unsigned xSkip = bufferPitch - width; |
|
|
|
|
|