[Scummvm-cvs-logs] scummvm master -> d5050463d52ef396f4e91e7780424ed19dd79fd2

bluegr md5 at scummvm.org
Thu May 26 10:49:21 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
984f53ac14 SWORD25 (LUA): Removed unused code for handling precompiled LUA scipts
d5050463d5 SWORD25: Removed the leftover libpng code


Commit: 984f53ac14cb0124caab39aba3e712dfc49a8ef5
    https://github.com/scummvm/scummvm/commit/984f53ac14cb0124caab39aba3e712dfc49a8ef5
Author: md5 (md5 at scummvm.org)
Date: 2011-05-26T01:46:41-07:00

Commit Message:
SWORD25 (LUA): Removed unused code for handling precompiled LUA scipts

Changed paths:
  R engines/sword25/util/lua/ldump.cpp
  R engines/sword25/util/lua/lundump.cpp
  R engines/sword25/util/lua/lundump.h
    engines/sword25/module.mk
    engines/sword25/util/lua/lapi.cpp
    engines/sword25/util/lua/ldo.cpp



diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk
index e87707d..2a568f5 100644
--- a/engines/sword25/module.mk
+++ b/engines/sword25/module.mk
@@ -60,7 +60,6 @@ MODULE_OBJS := \
 	util/lua/ldblib.o \
 	util/lua/ldebug.o \
 	util/lua/ldo.o \
-	util/lua/ldump.o \
 	util/lua/lfunc.o \
 	util/lua/lgc.o \
 	util/lua/linit.o \
@@ -79,7 +78,6 @@ MODULE_OBJS := \
 	util/lua/ltable.o \
 	util/lua/ltablib.o \
 	util/lua/ltm.o \
-	util/lua/lundump.o \
 	util/lua/lvm.o \
 	util/lua/lzio.o \
 	util/lua/scummvm_file.o \
diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp
index b1118db..16f8460 100644
--- a/engines/sword25/util/lua/lapi.cpp
+++ b/engines/sword25/util/lua/lapi.cpp
@@ -26,9 +26,8 @@
 #include "lstring.h"
 #include "ltable.h"
 #include "ltm.h"
-#include "lundump.h"
 #include "lvm.h"
-
+#include "common/textconsole.h"
 
 
 const char lua_ident[] =
@@ -876,17 +875,8 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
 
 
 LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
-  int status;
-  TValue *o;
-  lua_lock(L);
-  api_checknelems(L, 1);
-  o = L->top - 1;
-  if (isLfunction(o))
-    status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
-  else
-    status = 1;
-  lua_unlock(L);
-  return status;
+  error("lua_dump not supported: Handling of precompiled LUA scripts has been removed in ScummVM");
+  return 1;	// error
 }
 
 
diff --git a/engines/sword25/util/lua/ldo.cpp b/engines/sword25/util/lua/ldo.cpp
index b699c5d..bbcdf98 100644
--- a/engines/sword25/util/lua/ldo.cpp
+++ b/engines/sword25/util/lua/ldo.cpp
@@ -36,10 +36,9 @@
 #include "lstring.h"
 #include "ltable.h"
 #include "ltm.h"
-#include "lundump.h"
 #include "lvm.h"
 #include "lzio.h"
-
+#include "common/textconsole.h"
 
 
 
@@ -514,8 +513,9 @@ static void f_parser (lua_State *L, void *ud) {
   struct SParser *p = cast(struct SParser *, ud);
   int c = luaZ_lookahead(p->z);
   luaC_checkGC(L);
-  tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
-                                                             &p->buff, p->name);
+  if (c == LUA_SIGNATURE[0])
+	  error("Handling of precompiled LUA scripts has been removed in ScummVM");
+  tf = luaY_parser(L, p->z, &p->buff, p->name);
   cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
   cl->l.p = tf;
   for (i = 0; i < tf->nups; i++)  /* initialize eventual upvalues */
diff --git a/engines/sword25/util/lua/ldump.cpp b/engines/sword25/util/lua/ldump.cpp
deleted file mode 100644
index 3ce1654..0000000
--- a/engines/sword25/util/lua/ldump.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-** $Id$
-** save precompiled Lua chunks
-** See Copyright Notice in lua.h
-*/
-
-#include <stddef.h>
-
-#define ldump_c
-#define LUA_CORE
-
-#include "lua.h"
-
-#include "lobject.h"
-#include "lstate.h"
-#include "lundump.h"
-
-typedef struct {
- lua_State* L;
- lua_Writer writer;
- void* data;
- int strip;
- int status;
-} DumpState;
-
-#define DumpMem(b,n,size,D)	DumpBlock(b,(n)*(size),D)
-#define DumpVar(x,D)	 	DumpMem(&x,1,sizeof(x),D)
-
-static void DumpBlock(const void* b, size_t size, DumpState* D)
-{
- if (D->status==0)
- {
-  lua_unlock(D->L);
-  D->status=(*D->writer)(D->L,b,size,D->data);
-  lua_lock(D->L);
- }
-}
-
-static void DumpChar(int y, DumpState* D)
-{
- char x=(char)y;
- DumpVar(x,D);
-}
-
-static void DumpInt(int x, DumpState* D)
-{
- DumpVar(x,D);
-}
-
-static void DumpNumber(lua_Number x, DumpState* D)
-{
- DumpVar(x,D);
-}
-
-static void DumpVector(const void* b, int n, size_t size, DumpState* D)
-{
- DumpInt(n,D);
- DumpMem(b,n,size,D);
-}
-
-static void DumpString(const TString* s, DumpState* D)
-{
- if (s==NULL || getstr(s)==NULL)
- {
-  size_t size=0;
-  DumpVar(size,D);
- }
- else
- {
-  size_t size=s->tsv.len+1;		/* include trailing '\0' */
-  DumpVar(size,D);
-  DumpBlock(getstr(s),size,D);
- }
-}
-
-#define DumpCode(f,D)	 DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
-
-static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
-
-static void DumpConstants(const Proto* f, DumpState* D)
-{
- int i,n=f->sizek;
- DumpInt(n,D);
- for (i=0; i<n; i++)
- {
-  const TValue* o=&f->k[i];
-  DumpChar(ttype(o),D);
-  switch (ttype(o))
-  {
-   case LUA_TNIL:
-	break;
-   case LUA_TBOOLEAN:
-	DumpChar(bvalue(o),D);
-	break;
-   case LUA_TNUMBER:
-	DumpNumber(nvalue(o),D);
-	break;
-   case LUA_TSTRING:
-	DumpString(rawtsvalue(o),D);
-	break;
-   default:
-	lua_assert(0);			/* cannot happen */
-	break;
-  }
- }
- n=f->sizep;
- DumpInt(n,D);
- for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
-}
-
-static void DumpDebug(const Proto* f, DumpState* D)
-{
- int i,n;
- n= (D->strip) ? 0 : f->sizelineinfo;
- DumpVector(f->lineinfo,n,sizeof(int),D);
- n= (D->strip) ? 0 : f->sizelocvars;
- DumpInt(n,D);
- for (i=0; i<n; i++)
- {
-  DumpString(f->locvars[i].varname,D);
-  DumpInt(f->locvars[i].startpc,D);
-  DumpInt(f->locvars[i].endpc,D);
- }
- n= (D->strip) ? 0 : f->sizeupvalues;
- DumpInt(n,D);
- for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
-}
-
-static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
-{
- DumpString((f->source==p || D->strip) ? NULL : f->source,D);
- DumpInt(f->linedefined,D);
- DumpInt(f->lastlinedefined,D);
- DumpChar(f->nups,D);
- DumpChar(f->numparams,D);
- DumpChar(f->is_vararg,D);
- DumpChar(f->maxstacksize,D);
- DumpCode(f,D);
- DumpConstants(f,D);
- DumpDebug(f,D);
-}
-
-static void DumpHeader(DumpState* D)
-{
- char h[LUAC_HEADERSIZE];
- luaU_header(h);
- DumpBlock(h,LUAC_HEADERSIZE,D);
-}
-
-/*
-** dump Lua function as precompiled chunk
-*/
-int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
-{
- DumpState D;
- D.L=L;
- D.writer=w;
- D.data=data;
- D.strip=strip;
- D.status=0;
- DumpHeader(&D);
- DumpFunction(f,NULL,&D);
- return D.status;
-}
diff --git a/engines/sword25/util/lua/lundump.cpp b/engines/sword25/util/lua/lundump.cpp
deleted file mode 100644
index 4ffc623..0000000
--- a/engines/sword25/util/lua/lundump.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
-** $Id$
-** load precompiled Lua chunks
-** See Copyright Notice in lua.h
-*/
-
-#include <string.h>
-
-#define lundump_c
-#define LUA_CORE
-
-#include "lua.h"
-
-#include "ldebug.h"
-#include "ldo.h"
-#include "lfunc.h"
-#include "lmem.h"
-#include "lobject.h"
-#include "lstring.h"
-#include "lundump.h"
-#include "lzio.h"
-
-typedef struct {
- lua_State* L;
- ZIO* Z;
- Mbuffer* b;
- const char* name;
-} LoadState;
-
-#ifdef LUAC_TRUST_BINARIES
-#define IF(c,s)
-#define error(S,s)
-#else
-#define IF(c,s)		if (c) error(S,s)
-
-static void error(LoadState* S, const char* why)
-{
- luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
- luaD_throw(S->L,LUA_ERRSYNTAX);
-}
-#endif
-
-#define LoadMem(S,b,n,size)	LoadBlock(S,b,(n)*(size))
-#define	LoadByte(S)		(lu_byte)LoadChar(S)
-#define LoadVar(S,x)		LoadMem(S,&x,1,sizeof(x))
-#define LoadVector(S,b,n,size)	LoadMem(S,b,n,size)
-
-static void LoadBlock(LoadState* S, void* b, size_t size)
-{
- size_t r=luaZ_read(S->Z,b,size);
- UNUSED(r);
- IF (r!=0, "unexpected end");
-}
-
-static int LoadChar(LoadState* S)
-{
- char x;
- LoadVar(S,x);
- return x;
-}
-
-static int LoadInt(LoadState* S)
-{
- int x;
- LoadVar(S,x);
- IF (x<0, "bad integer");
- return x;
-}
-
-static lua_Number LoadNumber(LoadState* S)
-{
- lua_Number x;
- LoadVar(S,x);
- return x;
-}
-
-static TString* LoadString(LoadState* S)
-{
- size_t size;
- LoadVar(S,size);
- if (size==0)
-  return NULL;
- else
- {
-  char* s=luaZ_openspace(S->L,S->b,size);
-  LoadBlock(S,s,size);
-  return luaS_newlstr(S->L,s,size-1);		/* remove trailing '\0' */
- }
-}
-
-static void LoadCode(LoadState* S, Proto* f)
-{
- int n=LoadInt(S);
- f->code=luaM_newvector(S->L,n,Instruction);
- f->sizecode=n;
- LoadVector(S,f->code,n,sizeof(Instruction));
-}
-
-static Proto* LoadFunction(LoadState* S, TString* p);
-
-static void LoadConstants(LoadState* S, Proto* f)
-{
- int i,n;
- n=LoadInt(S);
- f->k=luaM_newvector(S->L,n,TValue);
- f->sizek=n;
- for (i=0; i<n; i++) setnilvalue(&f->k[i]);
- for (i=0; i<n; i++)
- {
-  TValue* o=&f->k[i];
-  int t=LoadChar(S);
-  switch (t)
-  {
-   case LUA_TNIL:
-   	setnilvalue(o);
-	break;
-   case LUA_TBOOLEAN:
-   	setbvalue(o,LoadChar(S));
-	break;
-   case LUA_TNUMBER:
-	setnvalue(o,LoadNumber(S));
-	break;
-   case LUA_TSTRING:
-	setsvalue2n(S->L,o,LoadString(S));
-	break;
-   default:
-	error(S,"bad constant");
-	break;
-  }
- }
- n=LoadInt(S);
- f->p=luaM_newvector(S->L,n,Proto*);
- f->sizep=n;
- for (i=0; i<n; i++) f->p[i]=NULL;
- for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
-}
-
-static void LoadDebug(LoadState* S, Proto* f)
-{
- int i,n;
- n=LoadInt(S);
- f->lineinfo=luaM_newvector(S->L,n,int);
- f->sizelineinfo=n;
- LoadVector(S,f->lineinfo,n,sizeof(int));
- n=LoadInt(S);
- f->locvars=luaM_newvector(S->L,n,LocVar);
- f->sizelocvars=n;
- for (i=0; i<n; i++) f->locvars[i].varname=NULL;
- for (i=0; i<n; i++)
- {
-  f->locvars[i].varname=LoadString(S);
-  f->locvars[i].startpc=LoadInt(S);
-  f->locvars[i].endpc=LoadInt(S);
- }
- n=LoadInt(S);
- f->upvalues=luaM_newvector(S->L,n,TString*);
- f->sizeupvalues=n;
- for (i=0; i<n; i++) f->upvalues[i]=NULL;
- for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
-}
-
-static Proto* LoadFunction(LoadState* S, TString* p)
-{
- Proto* f=luaF_newproto(S->L);
- setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
- f->source=LoadString(S); if (f->source==NULL) f->source=p;
- f->linedefined=LoadInt(S);
- f->lastlinedefined=LoadInt(S);
- f->nups=LoadByte(S);
- f->numparams=LoadByte(S);
- f->is_vararg=LoadByte(S);
- f->maxstacksize=LoadByte(S);
- LoadCode(S,f);
- LoadConstants(S,f);
- LoadDebug(S,f);
- IF (!luaG_checkcode(f), "bad code");
- S->L->top--;
- return f;
-}
-
-static void LoadHeader(LoadState* S)
-{
- char h[LUAC_HEADERSIZE];
- char s[LUAC_HEADERSIZE];
- luaU_header(h);
- LoadBlock(S,s,LUAC_HEADERSIZE);
- IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
-}
-
-/*
-** load precompiled chunk
-*/
-Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
-{
- LoadState S;
- if (*name=='@' || *name=='=')
-  S.name=name+1;
- else if (*name==LUA_SIGNATURE[0])
-  S.name="binary string";
- else
-  S.name=name;
- S.L=L;
- S.Z=Z;
- S.b=buff;
- LoadHeader(&S);
- return LoadFunction(&S,luaS_newliteral(L,"=?"));
-}
-
-/*
-* make header
-*/
-void luaU_header (char* h)
-{
- int x=1;
- memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
- h+=sizeof(LUA_SIGNATURE)-1;
- *h++=(char)LUAC_VERSION;
- *h++=(char)LUAC_FORMAT;
- *h++=(char)*(char*)&x;				/* endianness */
- *h++=(char)sizeof(int);
- *h++=(char)sizeof(size_t);
- *h++=(char)sizeof(Instruction);
- *h++=(char)sizeof(lua_Number);
- *h++=(char)(((lua_Number)0.5)==0);		/* is lua_Number integral? */
-}
diff --git a/engines/sword25/util/lua/lundump.h b/engines/sword25/util/lua/lundump.h
deleted file mode 100644
index c293c56..0000000
--- a/engines/sword25/util/lua/lundump.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-** $Id$
-** load precompiled Lua chunks
-** See Copyright Notice in lua.h
-*/
-
-#ifndef lundump_h
-#define lundump_h
-
-#include "lobject.h"
-#include "lzio.h"
-
-/* load one chunk; from lundump.c */
-LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
-
-/* make header; from lundump.c */
-LUAI_FUNC void luaU_header (char* h);
-
-/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
-
-/* for header of binary files -- this is Lua 5.1 */
-#define LUAC_VERSION		0x51
-
-/* for header of binary files -- this is the official format */
-#define LUAC_FORMAT		0
-
-/* size of header of binary files */
-#define LUAC_HEADERSIZE		12
-
-#endif


Commit: d5050463d52ef396f4e91e7780424ed19dd79fd2
    https://github.com/scummvm/scummvm/commit/d5050463d52ef396f4e91e7780424ed19dd79fd2
Author: md5 (md5 at scummvm.org)
Date: 2011-05-26T01:46:42-07:00

Commit Message:
SWORD25: Removed the leftover libpng code

Changed paths:
    engines/sword25/gfx/image/pngloader.cpp
    engines/sword25/gfx/image/pngloader.h
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/image/swimage.cpp



diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index 6f370d8..9219940 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -29,141 +29,15 @@
  *
  */
 
-#ifndef USE_INTERNAL_PNG_DECODER
-// Disable symbol overrides so that we can use png.h
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-#endif
-
 #include "common/memstream.h"
 #include "sword25/gfx/image/image.h"
 #include "sword25/gfx/image/pngloader.h"
-#ifndef USE_INTERNAL_PNG_DECODER
-#include <png.h>
-#else
 #include "graphics/pixelformat.h"
 #include "graphics/png.h"
-#endif
 
 namespace Sword25 {
 
-#ifndef USE_INTERNAL_PNG_DECODER
-static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
-	const byte **ref = (const byte **)png_get_io_ptr(png_ptr);
-	memcpy(data, *ref, length);
-	*ref += length;
-}
-
-static bool doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
-	return (fileSize > 8) && png_check_sig(const_cast<byte *>(fileDataPtr), 8);
-}
-#endif
-
-bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
-#ifndef USE_INTERNAL_PNG_DECODER
-	png_structp png_ptr = NULL;
-	png_infop   info_ptr = NULL;
-
-	int         bitDepth;
-	int         colorType;
-	int         interlaceType;
-	int         i;
-
-	// Check for valid PNG signature
-	if (!doIsCorrectImageFormat(fileDataPtr, fileSize)) {
-		error("png_check_sig failed");
-	}
-
-	// Create both PNG structures
-	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-	if (!png_ptr) {
-		error("Could not create libpng read struct.");
-	}
-
-	info_ptr = png_create_info_struct(png_ptr);
-	if (!info_ptr) {
-		error("Could not create libpng info struct.");
-	}
-
-	// Use alternative reading function
-	const byte **ref = &fileDataPtr;
-	png_set_read_fn(png_ptr, (void *)ref, png_user_read_data);
-
-	// Read PNG header
-	png_read_info(png_ptr, info_ptr);
-
-	// Read out PNG informations
-
-	png_uint_32 w, h;
-	png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, &interlaceType, NULL, NULL);
-	width = w;
-	height = h;
-
-	// Calculate pitch of output image
-	pitch = GraphicEngine::calcPitch(GraphicEngine::CF_ARGB32, width);
-
-	// Allocate memory for the final image data.
-	// To keep memory framentation low this happens before allocating memory for temporary image data.
-	uncompressedDataPtr = new byte[pitch * height];
-	if (!uncompressedDataPtr) {
-		error("Could not allocate memory for output image.");
-	}
-
-	// Images of all color formates will be transformed into ARGB images
-	if (bitDepth == 16)
-		png_set_strip_16(png_ptr);
-	if (colorType == PNG_COLOR_TYPE_PALETTE)
-		png_set_expand(png_ptr);
-	if (bitDepth < 8)
-		png_set_expand(png_ptr);
-	if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
-		png_set_expand(png_ptr);
-	if (colorType == PNG_COLOR_TYPE_GRAY ||
-	        colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
-		png_set_gray_to_rgb(png_ptr);
-
-	png_set_bgr(png_ptr);
-
-	if (colorType != PNG_COLOR_TYPE_RGB_ALPHA)
-		png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
-
-	// After the transformations have been registered, the image data is read again.
-	png_read_update_info(png_ptr, info_ptr);
-	png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL);
-	width = w;
-	height = h;
-
-	if (interlaceType == PNG_INTERLACE_NONE) {
-		// PNGs without interlacing can simply be read row by row.
-		for (i = 0; i < height; i++) {
-			png_read_row(png_ptr, uncompressedDataPtr + i * pitch, NULL);
-		}
-	} else {
-		// PNGs with interlacing require us to allocate an auxillary
-		// buffer with pointers to all row starts.
-
-		// Allocate row pointer buffer
-		png_bytep *pRowPtr = new png_bytep[height];
-		if (!pRowPtr) {
-			error("Could not allocate memory for row pointers.");
-		}
-
-		// Initialize row pointers
-		for (i = 0; i < height; i++)
-			pRowPtr[i] = uncompressedDataPtr + i * pitch;
-
-		// Read image data
-		png_read_image(png_ptr, pRowPtr);
-
-		// Free row pointer buffer
-		delete[] pRowPtr;
-	}
-
-	// Read additional data at the end.
-	png_read_end(png_ptr, NULL);
-
-	// Destroy libpng structures
-	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-#else
+bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
 	Common::MemoryReadStream *fileStr = new Common::MemoryReadStream(fileDataPtr, fileSize, DisposeAfterUse::NO);
 	Graphics::PNG *png = new Graphics::PNG();
 	if (!png->read(fileStr))	// the fileStr pointer, and thus pFileData will be deleted after this is done
@@ -181,65 +55,8 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&unc
 	delete pngSurface;
 	delete png;
 
-#endif
 	// Signal success
 	return true;
 }
 
-bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
-	return doDecodeImage(fileDataPtr, fileSize, uncompressedDataPtr, width, height, pitch);
-}
-
-#ifndef USE_INTERNAL_PNG_DECODER
-bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
-	// Check for valid PNG signature
-	if (!doIsCorrectImageFormat(fileDataPtr, fileSize))
-		return false;
-
-	png_structp png_ptr = NULL;
-	png_infop info_ptr = NULL;
-
-	// Create both PNG structures
-	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-	if (!png_ptr) {
-		error("Could not create libpng read struct.");
-	}
-
-	info_ptr = png_create_info_struct(png_ptr);
-	if (!info_ptr) {
-		error("Could not create libpng info struct.");
-	}
-
-	// Use alternative reading function
-	const byte **ref = &fileDataPtr;
-	png_set_read_fn(png_ptr, (void *)ref, png_user_read_data);
-
-	// Read PNG Header
-	png_read_info(png_ptr, info_ptr);
-
-	// Read out PNG informations
-	int bitDepth;
-	int colorType;
-	png_uint_32 w, h;
-	png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL);
-
-	width = w;
-	height = h;
-
-	// Destroy libpng structures
-	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-
-	return true;
-
-}
-
-bool PNGLoader::imageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
-	return doImageProperties(fileDataPtr, fileSize, width, height);
-}
-
-#else
-	// We don't need to read the image properties here...
-#endif
-
-
 } // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/pngloader.h b/engines/sword25/gfx/image/pngloader.h
index 6b5f65f..3f90931 100644
--- a/engines/sword25/gfx/image/pngloader.h
+++ b/engines/sword25/gfx/image/pngloader.h
@@ -37,9 +37,6 @@
 
 namespace Sword25 {
 
-// Define to use ScummVM's PNG decoder, instead of libpng
-#define USE_INTERNAL_PNG_DECODER
-
 /**
  * Class for loading PNG files, and PNG data embedded into savegames.
  *
@@ -49,11 +46,6 @@ class PNGLoader {
 protected:
 	PNGLoader() {}	// Protected constructor to prevent instances
 
-	static bool doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch);
-#ifndef USE_INTERNAL_PNG_DECODER
-	static bool doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height);
-#endif
-
 public:
 
 	/**
@@ -74,24 +66,6 @@ public:
 	                        byte *&pUncompressedData,
 	                        int &width, int &height,
 	                        int &pitch);
-
-#ifndef USE_INTERNAL_PNG_DECODER
-	/**
-	 * Extract the properties of an image.
-	 * @param[in] fileDatePtr	pointer to the image data
-	 * @param[in] fileSize		size of the image data in bytes
-	 * @param[out] width		if successful, this is set to the width of the image
-	 * @param[out] height		if successful, this is set to the height of the image
-	 * @return returns true if extraction of the properties was successful, false in case of an error
-	 *
-	 * @remark This function does not free the image buffer passed to it,
-	 *         it is the callers responsibility to do so.
-	 */
-	static bool imageProperties(const byte *fileDatePtr, uint fileSize,
-	                            int &width,
-	                            int &height);
-#endif
-
 };
 
 } // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 395d29d..476d293 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -145,15 +145,6 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
 		return;
 	}
 
-#ifndef USE_INTERNAL_PNG_DECODER
-	// Determine image properties
-	if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
-		error("Could not read image properties.");
-		delete[] pFileData;
-		return;
-	}
-#endif
-
 	// Uncompress the image
 	int pitch;
 	if (isPNG)
diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp
index 92d4736..0978eb5 100644
--- a/engines/sword25/gfx/image/swimage.cpp
+++ b/engines/sword25/gfx/image/swimage.cpp
@@ -53,14 +53,6 @@ SWImage::SWImage(const Common::String &filename, bool &result) :
 		return;
 	}
 
-#ifndef USE_INTERNAL_PNG_DECODER
-	// Determine image properties
-	if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
-		error("Could not read image properties.");
-		return;
-	}
-#endif
-
 	// Uncompress the image
 	int pitch;
 	byte *pUncompressedData;






More information about the Scummvm-git-logs mailing list