X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8141573c1ed2d7f02b201c7b78f32ffca2925eeb..1be06faf7318abf88a35b299b90ceb2a49c0353b:/src/common/gifdecod.cpp diff --git a/src/common/gifdecod.cpp b/src/common/gifdecod.cpp index c746a8574f..c08bf1fdf6 100644 --- a/src/common/gifdecod.cpp +++ b/src/common/gifdecod.cpp @@ -36,7 +36,7 @@ wxGIFDecoder::wxGIFDecoder(wxInputStream *s, bool anim) { - m_f = s; + m_f = s; m_anim = anim; m_background = -1; @@ -69,6 +69,12 @@ void wxGIFDecoder::Destroy() delete pimg; pimg = paux; } + + m_pimage = NULL; + m_pfirst = NULL; + m_plast = NULL; + m_image = 0; + m_nimages = 0; } @@ -120,6 +126,25 @@ bool wxGIFDecoder::ConvertToImage(wxImage *image) const else image->SetMask(FALSE); + // Set the palette + // Palette creation not yet implemented on wxGTK +#ifndef __WXGTK__ + if (pal) + { + unsigned char* r = new unsigned char[256]; + unsigned char* g = new unsigned char[256]; + unsigned char* b = new unsigned char[256]; + for (i = 0; i < 256; i++) + { + r[i] = pal[3*i + 0]; + g[i] = pal[3*i + 1]; + b[i] = pal[3*i + 2]; + } + image->SetPalette(wxPalette(256, r, g, b)); + delete[] r; delete[] g; delete[] b; + } +#endif + /* copy image data */ for (i = 0; i < (GetWidth() * GetHeight()); i++, src++) { @@ -311,10 +336,15 @@ int wxGIFDecoder::getcode(int bits, int ab_fin) // int wxGIFDecoder::dgif(GIFImage *img, int interl, int bits) { +#ifdef __WXMAC__ + int *ab_prefix = new int[4096]; /* alphabet (prefixes) */ + int *ab_tail = new int[4096]; /* alphabet (tails) */ + int *stack = new int[4096]; /* decompression stack */ +#else int ab_prefix[4096]; /* alphabet (prefixes) */ int ab_tail[4096]; /* alphabet (tails) */ int stack[4096]; /* decompression stack */ - +#endif int ab_clr; /* clear code */ int ab_fin; /* end of info code */ int ab_bits; /* actual symbol width, in bits */ @@ -438,6 +468,11 @@ int wxGIFDecoder::dgif(GIFImage *img, int interl, int bits) } while (code != ab_fin); +#ifdef __WXMAC__ + delete [] ab_prefix ; + delete [] ab_tail ; + delete [] stack ; +#endif return 0; } @@ -470,7 +505,7 @@ int wxGIFDecoder::ReadGIF() int ncolors, bits, interl, transparent, disposal, i; long size; long delay; - unsigned char type; + unsigned char type = 0; unsigned char pal[768]; unsigned char buf[16]; GIFImage **ppimg, *pimg, *pprev; @@ -643,7 +678,7 @@ int wxGIFDecoder::ReadGIF() if ((buf[8] & 0x80) == 0x80) { ncolors = 2 << (buf[8] & 0x07); - m_f->Read(pal, 3 * ncolors); + m_f->SeekI(3 * ncolors, wxFromCurrent); } /* initial code size */ @@ -655,7 +690,7 @@ int wxGIFDecoder::ReadGIF() m_f->SeekI(i, wxFromCurrent); } } - else if (type != 0x3B) + else if ((type != 0x3B) && (type != 00)) /* testing */ { /* images are OK, but couldn't read to the end of the stream */ return wxGIF_TRUNCATED;