summaryrefslogtreecommitdiff
path: root/libs/freeimage/src/FreeImage/PluginGIF.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-12-26 16:39:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-12-26 16:39:04 +0300
commit62a186697df33c96dc1a6dac0f4dfc38652fb96f (patch)
tree1437d0906218fae8827aed384026f2b7e656f4ac /libs/freeimage/src/FreeImage/PluginGIF.cpp
parentfcbb395dc7ff3edab972b6d4b27dbbfb3305f5d7 (diff)
BYTE -> uint8_t
Diffstat (limited to 'libs/freeimage/src/FreeImage/PluginGIF.cpp')
-rw-r--r--libs/freeimage/src/FreeImage/PluginGIF.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/libs/freeimage/src/FreeImage/PluginGIF.cpp b/libs/freeimage/src/FreeImage/PluginGIF.cpp
index 8fe0422b31..b1c823bdc8 100644
--- a/libs/freeimage/src/FreeImage/PluginGIF.cpp
+++ b/libs/freeimage/src/FreeImage/PluginGIF.cpp
@@ -51,7 +51,7 @@ struct GIFinfo {
//only really used when reading
size_t global_color_table_offset;
int global_color_table_size;
- BYTE background_color;
+ uint8_t background_color;
std::vector<size_t> application_extension_offsets;
std::vector<size_t> comment_extension_offsets;
std::vector<size_t> graphic_control_extension_offsets;
@@ -79,11 +79,11 @@ public:
StringTable();
~StringTable();
void Initialize(int minCodeSize);
- BYTE *FillInputBuffer(int len);
+ uint8_t *FillInputBuffer(int len);
void CompressStart(int bpp, int width);
- int CompressEnd(BYTE *buf); //0-4 bytes
- bool Compress(BYTE *buf, int *len);
- bool Decompress(BYTE *buf, int *len);
+ int CompressEnd(uint8_t *buf); //0-4 bytes
+ bool Compress(uint8_t *buf, int *len);
+ bool Decompress(uint8_t *buf, int *len);
void Done(void);
protected:
@@ -105,7 +105,7 @@ protected:
int* m_strmap;
//input buffer
- BYTE *m_buffer;
+ uint8_t *m_buffer;
int m_bufferSize, m_bufferRealSize, m_bufferPos, m_bufferShift;
void ClearCompressorTable(void);
@@ -220,14 +220,14 @@ void StringTable::Initialize(int minCodeSize)
ClearDecompressorTable();
}
-BYTE *StringTable::FillInputBuffer(int len)
+uint8_t *StringTable::FillInputBuffer(int len)
{
if( m_buffer == NULL ) {
- m_buffer = new(std::nothrow) BYTE[len];
+ m_buffer = new(std::nothrow) uint8_t[len];
m_bufferRealSize = len;
} else if( len > m_bufferRealSize ) {
delete [] m_buffer;
- m_buffer = new(std::nothrow) BYTE[len];
+ m_buffer = new(std::nothrow) uint8_t[len];
m_bufferRealSize = len;
}
m_bufferSize = len;
@@ -246,7 +246,7 @@ void StringTable::CompressStart(int bpp, int width)
ClearCompressorTable();
}
-int StringTable::CompressEnd(BYTE *buf)
+int StringTable::CompressEnd(uint8_t *buf)
{
int len = 0;
@@ -254,7 +254,7 @@ int StringTable::CompressEnd(BYTE *buf)
m_partial |= m_prefix << m_partialSize;
m_partialSize += m_codeSize;
while( m_partialSize >= 8 ) {
- *buf++ = (BYTE)m_partial;
+ *buf++ = (uint8_t)m_partial;
m_partial >>= 8;
m_partialSize -= 8;
len++;
@@ -264,7 +264,7 @@ int StringTable::CompressEnd(BYTE *buf)
m_partial |= m_endCode << m_partialSize;
m_partialSize += m_codeSize;
while( m_partialSize > 0 ) {
- *buf++ = (BYTE)m_partial;
+ *buf++ = (uint8_t)m_partial;
m_partial >>= 8;
m_partialSize -= 8;
len++;
@@ -275,14 +275,14 @@ int StringTable::CompressEnd(BYTE *buf)
return len;
}
-bool StringTable::Compress(BYTE *buf, int *len)
+bool StringTable::Compress(uint8_t *buf, int *len)
{
if( m_bufferSize == 0 || m_done ) {
return false;
}
int mask = (1 << m_bpp) - 1;
- BYTE *bufpos = buf;
+ uint8_t *bufpos = buf;
while( m_bufferPos < m_bufferSize ) {
//get the current pixel value
char ch = (char)((m_buffer[m_bufferPos] >> m_bufferShift) & mask);
@@ -299,7 +299,7 @@ bool StringTable::Compress(BYTE *buf, int *len)
m_partialSize += m_codeSize;
//grab full bytes for the output buffer
while( m_partialSize >= 8 && bufpos - buf < *len ) {
- *bufpos++ = (BYTE)m_partial;
+ *bufpos++ = (uint8_t)m_partial;
m_partial >>= 8;
m_partialSize -= 8;
}
@@ -365,13 +365,13 @@ bool StringTable::Compress(BYTE *buf, int *len)
return true;
}
-bool StringTable::Decompress(BYTE *buf, int *len)
+bool StringTable::Decompress(uint8_t *buf, int *len)
{
if( m_bufferSize == 0 || m_done ) {
return false;
}
- BYTE *bufpos = buf;
+ uint8_t *bufpos = buf;
for( ; m_bufferPos < m_bufferSize; m_bufferPos++ ) {
m_partial |= (int)m_buffer[m_bufferPos] << m_partialSize;
m_partialSize += 8;
@@ -495,9 +495,9 @@ MimeType() {
static BOOL DLL_CALLCONV
Validate(FreeImageIO *io, fi_handle handle) {
- BYTE GIF89a[] = { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 }; // ASCII code for "GIF89a"
- BYTE GIF87a[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }; // ASCII code for "GIF87a"
- BYTE signature[6] = { 0, 0, 0, 0, 0, 0 };
+ uint8_t GIF89a[] = { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 }; // ASCII code for "GIF89a"
+ uint8_t GIF87a[] = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }; // ASCII code for "GIF87a"
+ uint8_t signature[6] = { 0, 0, 0, 0, 0, 0 };
io->read_proc(signature, 1, 6, handle);
@@ -542,7 +542,7 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) {
//Logical Screen Descriptor
io->seek_proc(handle, 4, SEEK_CUR);
- BYTE packed;
+ uint8_t packed;
if( io->read_proc(&packed, 1, 1, handle) < 1 ) {
throw "EOF reading Logical Screen Descriptor";
}
@@ -560,7 +560,7 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) {
//Scan through all the rest of the blocks, saving offsets
size_t gce_offset = 0;
- BYTE block = 0;
+ uint8_t block = 0;
while( block != GIF_BLOCK_TRAILER ) {
if( io->read_proc(&block, 1, 1, handle) < 1 ) {
throw "EOF reading blocks";
@@ -584,7 +584,7 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) {
//LZW Minimum Code Size
io->seek_proc(handle, 1, SEEK_CUR);
} else if( block == GIF_BLOCK_EXTENSION ) {
- BYTE ext;
+ uint8_t ext;
if( io->read_proc(&ext, 1, 1, handle) < 1 ) {
throw "EOF reading extension";
}
@@ -604,7 +604,7 @@ Open(FreeImageIO *io, fi_handle handle, BOOL read) {
}
//Data Sub-blocks
- BYTE len;
+ uint8_t len;
if( io->read_proc(&len, 1, 1, handle) < 1 ) {
throw "EOF reading sub-block";
}
@@ -637,7 +637,7 @@ Close(FreeImageIO *io, fi_handle handle, void *data) {
if( !info->read ) {
//Trailer
- BYTE b = GIF_BLOCK_TRAILER;
+ uint8_t b = GIF_BLOCK_TRAILER;
io->write_proc(&b, 1, 1, handle);
}
@@ -673,7 +673,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
bool have_transparent = false, no_local_palette = false, interlaced = false;
int disposal_method = GIF_DISPOSAL_LEAVE, delay_time = 0, transparent_color = 0;
WORD left, top, width, height;
- BYTE packed, b;
+ uint8_t packed, b;
WORD w;
//playback pages to generate what the user would see for this frame
@@ -791,7 +791,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
have_transparent = false;
if( FreeImage_IsTransparent(pagedib) ) {
int count = FreeImage_GetTransparencyCount(pagedib);
- BYTE *table = FreeImage_GetTransparencyTable(pagedib);
+ uint8_t *table = FreeImage_GetTransparencyTable(pagedib);
for( int i = 0; i < count; i++ ) {
if( table[i] == 0 ) {
have_transparent = true;
@@ -807,7 +807,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
break; // If data is corrupt, don't calculate in invalid scanline
}
scanline = (RGBQUAD *)FreeImage_GetScanLine(dib, scanidx) + info.left;
- BYTE *pageline = FreeImage_GetScanLine(pagedib, info.height - y - 1);
+ uint8_t *pageline = FreeImage_GetScanLine(pagedib, info.height - y - 1);
for( x = 0; x < info.width; x++ ) {
if( !have_transparent || *pageline != transparent_color ) {
*scanline = pal[*pageline];
@@ -902,9 +902,9 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
} else {
//its legal to have no palette, but we're going to generate *something*
for( int i = 0; i < 256; i++ ) {
- pal[i].rgbRed = (BYTE)i;
- pal[i].rgbGreen = (BYTE)i;
- pal[i].rgbBlue = (BYTE)i;
+ pal[i].rgbRed = (uint8_t)i;
+ pal[i].rgbGreen = (uint8_t)i;
+ pal[i].rgbBlue = (uint8_t)i;
}
}
@@ -915,8 +915,8 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
//Image Data Sub-blocks
int x = 0, xpos = 0, y = 0, shift = 8 - bpp, mask = (1 << bpp) - 1, interlacepass = 0;
- BYTE *scanline = FreeImage_GetScanLine(dib, height - 1);
- BYTE buf[4096];
+ uint8_t *scanline = FreeImage_GetScanLine(dib, height - 1);
+ uint8_t buf[4096];
io->read_proc(&b, 1, 1, handle);
while( b ) {
io->read_proc(stringtable->FillInputBuffer(b), b, 1, handle);
@@ -1046,7 +1046,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
if( have_transparent ) {
int size = 1 << bpp;
if( transparent_color <= size ) {
- BYTE table[256];
+ uint8_t table[256];
memset(table, 0xFF, size);
table[transparent_color] = 0;
FreeImage_SetTransparencyTable(dib, table, size);
@@ -1054,7 +1054,7 @@ Load(FreeImageIO *io, fi_handle handle, int page, int flags, void *data) {
}
}
FreeImage_SetMetadataEx(FIMD_ANIMATION, dib, "FrameTime", ANIMTAG_FRAMETIME, FIDT_LONG, 1, 4, &delay_time);
- b = (BYTE)disposal_method;
+ b = (uint8_t)disposal_method;
FreeImage_SetMetadataEx(FIMD_ANIMATION, dib, "DisposalMethod", ANIMTAG_DISPOSALMETHOD, FIDT_BYTE, 1, 1, &b);
delete stringtable;
@@ -1082,7 +1082,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
}
try {
- BYTE packed, b;
+ uint8_t packed, b;
WORD w;
FITAG *tag;
@@ -1102,16 +1102,16 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
top = *(WORD *)FreeImage_GetTagValue(tag);
}
if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "NoLocalPalette", FIDT_BYTE, &tag) ) {
- no_local_palette = *(BYTE *)FreeImage_GetTagValue(tag) ? true : false;
+ no_local_palette = *(uint8_t *)FreeImage_GetTagValue(tag) ? true : false;
}
if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "Interlaced", FIDT_BYTE, &tag) ) {
- interlaced = *(BYTE *)FreeImage_GetTagValue(tag) ? true : false;
+ interlaced = *(uint8_t *)FreeImage_GetTagValue(tag) ? true : false;
}
if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "FrameTime", FIDT_LONG, &tag) ) {
delay_time = *(LONG *)FreeImage_GetTagValue(tag);
}
if( FreeImage_GetMetadataEx(FIMD_ANIMATION, dib, "DisposalMethod", FIDT_BYTE, &tag) ) {
- disposal_method = *(BYTE *)FreeImage_GetTagValue(tag);
+ disposal_method = *(uint8_t *)FreeImage_GetTagValue(tag);
}
RGBQUAD *pal = FreeImage_GetPalette(dib);
@@ -1186,7 +1186,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
background_color.rgbGreen == globalpalette[i].rgbGreen &&
background_color.rgbBlue == globalpalette[i].rgbBlue ) {
- b = (BYTE)i;
+ b = (uint8_t)i;
break;
}
}
@@ -1240,7 +1240,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
char *value = (char *)FreeImage_GetTagValue(tag);
io->write_proc((void *)"\x21\xFE", 2, 1, handle);
while( length > 0 ) {
- b = (BYTE)(length >= 255 ? 255 : length);
+ b = (uint8_t)(length >= 255 ? 255 : length);
io->write_proc(&b, 1, 1, handle);
io->write_proc(value, b, 1, handle);
value += b;
@@ -1258,7 +1258,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
//Graphic Control Extension
if( FreeImage_IsTransparent(dib) ) {
int count = FreeImage_GetTransparencyCount(dib);
- BYTE *table = FreeImage_GetTransparencyTable(dib);
+ uint8_t *table = FreeImage_GetTransparencyTable(dib);
for( int i = 0; i < count; i++ ) {
if( table[i] == 0 ) {
have_transparent = true;
@@ -1268,7 +1268,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
}
}
io->write_proc((void *)"\x21\xF9\x04", 3, 1, handle);
- b = (BYTE)((disposal_method << 2) & GIF_PACKED_GCE_DISPOSAL);
+ b = (uint8_t)((disposal_method << 2) & GIF_PACKED_GCE_DISPOSAL);
if( have_transparent ) b |= GIF_PACKED_GCE_HAVETRANS;
io->write_proc(&b, 1, 1, handle);
//Notes about delay time for GIFs:
@@ -1280,7 +1280,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
SwapShort(&w);
#endif
io->write_proc(&w, 2, 1, handle);
- b = (BYTE)transparent_color;
+ b = (uint8_t)transparent_color;
io->write_proc(&b, 1, 1, handle);
b = 0;
io->write_proc(&b, 1, 1, handle);
@@ -1309,7 +1309,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
//LZW Minimum Code Size
- b = (BYTE)(bpp == 1 ? 2 : bpp);
+ b = (uint8_t)(bpp == 1 ? 2 : bpp);
io->write_proc(&b, 1, 1, handle);
StringTable *stringtable = new(std::nothrow) StringTable;
stringtable->Initialize(b);
@@ -1317,7 +1317,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
//Image Data Sub-blocks
int y = 0, interlacepass = 0, line = FreeImage_GetLine(dib);
- BYTE buf[255], *bufptr = buf; //255 is the max sub-block length
+ uint8_t buf[255], *bufptr = buf; //255 is the max sub-block length
int size = sizeof(buf);
b = sizeof(buf);
while( y < output_height ) {
@@ -1343,7 +1343,7 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
}
}
size = (int)(bufptr - buf);
- BYTE last[4];
+ uint8_t last[4];
w = (WORD)stringtable->CompressEnd(last);
if( size + w >= sizeof(buf) ) {
//one last full size sub-block
@@ -1351,14 +1351,14 @@ Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void
io->write_proc(buf, size, 1, handle);
io->write_proc(last, sizeof(buf) - size, 1, handle);
//and possibly a tiny additional sub-block
- b = (BYTE)(w - (sizeof(buf) - size));
+ b = (uint8_t)(w - (sizeof(buf) - size));
if( b > 0 ) {
io->write_proc(&b, 1, 1, handle);
io->write_proc(last + w - b, b, 1, handle);
}
} else {
//last sub-block less than full size
- b = (BYTE)(size + w);
+ b = (uint8_t)(size + w);
io->write_proc(&b, 1, 1, handle);
io->write_proc(buf, size, 1, handle);
io->write_proc(last, w, 1, handle);