From 2fc7b29312a126e48524b7f63a809ab7ee813fe2 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 7 Nov 2010 10:58:31 +0000 Subject: [PATCH] *plugin/gif: Support for LCT (and couple of 64bits fixes) git-svn-id: svn://ultimatepp.org/upp/trunk@2838 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Stream.cpp | 2 +- uppsrc/Core/String.h | 4 ++-- uppsrc/Core/Util.cpp | 4 ++-- uppsrc/CtrlLib/FileList.cpp | 2 +- uppsrc/plugin/gif/gifupp.cpp | 22 +++++++++++++++++----- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/uppsrc/Core/Stream.cpp b/uppsrc/Core/Stream.cpp index af3d7d1b3..d2eddd02a 100644 --- a/uppsrc/Core/Stream.cpp +++ b/uppsrc/Core/Stream.cpp @@ -1139,7 +1139,7 @@ void OutStream::_Put(const void *data, dword size) void OutStream::Flush() { if(ptr != buffer) { - Out(buffer, ptr - buffer); + Out(buffer, int(ptr - buffer)); ptr = h; } } diff --git a/uppsrc/Core/String.h b/uppsrc/Core/String.h index 8883848d2..ab03d05ad 100644 --- a/uppsrc/Core/String.h +++ b/uppsrc/Core/String.h @@ -374,7 +374,7 @@ public: void Cat(int c) { if(end >= limit) Expand(); *end++ = c; } void Cat(int c, int count); void Cat(const char *s, int l); - void Cat(const char *s, const char *e) { Cat(s, e - s); } + void Cat(const char *s, const char *e) { Cat(s, int(e - s)); } void Cat(const char *s) { Cat(s, (int)strlen(s)); } void Cat(const String& s) { Cat(s, s.GetLength()); } @@ -738,7 +738,7 @@ public: void Cat(int c) { if(end >= limit) Expand(); *end++ = c; } void Cat(int c, int count); void Cat(const wchar *s, int l); - void Cat(const wchar *s, const wchar *e) { Cat(s, e - s); } + void Cat(const wchar *s, const wchar *e) { Cat(s, int(e - s)); } void Cat(const wchar *s) { Cat(s, wstrlen(s)); } void Cat(const WString& s) { Cat(s, s.GetLength()); } void Cat(const char *s) { Cat(WString(s)); } diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index a72475176..8355b89a3 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -22,7 +22,7 @@ void PanicMessageBox(const char *title, const char *text) if(sPanicMessageBox) (*sPanicMessageBox)(title, text); else { - write(2, text, strlen(text)); + write(2, text, (int)strlen(text)); write(2, "\n", 1); } } @@ -573,7 +573,7 @@ String HexString(const String& s, int sep, int sepchr) String ScanHexString(const char *s, const char *lim) { String r; - r.Reserve((lim - s) / 2); + r.Reserve(int(lim - s) / 2); for(;;) { byte b = 0; while(!IsXDigit(*s)) { diff --git a/uppsrc/CtrlLib/FileList.cpp b/uppsrc/CtrlLib/FileList.cpp index fce9b5f48..8bd251bfe 100644 --- a/uppsrc/CtrlLib/FileList.cpp +++ b/uppsrc/CtrlLib/FileList.cpp @@ -160,7 +160,7 @@ void FileList::StartEdit() { edit = cf.name.ToWString(); edit.Show(); edit.SetFocus(); - int pos = GetFileExtPos(cf.name) - ~cf.name; + int pos = int(GetFileExtPos(cf.name) - ~cf.name); edit.SetSelection(0, pos); } diff --git a/uppsrc/plugin/gif/gifupp.cpp b/uppsrc/plugin/gif/gifupp.cpp index a5a5616b5..55c168cf2 100644 --- a/uppsrc/plugin/gif/gifupp.cpp +++ b/uppsrc/plugin/gif/gifupp.cpp @@ -193,6 +193,7 @@ private: GIFRaster& owner; Stream& stream; RasterFormat format; + RGBA gpalette[256]; RGBA palette[256]; GifGlobalInfo ggi; Vector temp; @@ -493,7 +494,18 @@ bool GIFRaster::Data::LoadSubimage(int64 &beginPos, int &delay, int &x, int &y, if(l.x + l.width > size.cx || l.y + l.height > size.cy) return false; // out of bitmap rectangle - // ignore LCT + memcpy(palette, gpalette, 256 * sizeof(RGBA)); + + if(l.lct_flag) { + stream.Seek(l.lct_fpos); + for(int i = 0; i < l.lct_recs; i++) { + palette[i].r = stream.Get(); + palette[i].g = stream.Get(); + palette[i].b = stream.Get(); + palette[i].a = 255; + } + } + stream.Seek(l.dat_fpos); if((start_bpp = stream.Get()) <= 0 || start_bpp > 12) @@ -523,10 +535,10 @@ bool GIFRaster::Data::Create() stream.Seek(ggi.gct_fpos); for(int i = 0; i < ggi.gct_recs; i++) { - palette[i].r = stream.Get(); - palette[i].g = stream.Get(); - palette[i].b = stream.Get(); - palette[i].a = 255; + gpalette[i].r = stream.Get(); + gpalette[i].g = stream.Get(); + gpalette[i].b = stream.Get(); + gpalette[i].a = 255; } format.Set8(); GetPagesData();