mirror of
https://github.com/libretro/stella2023.git
synced 2024-11-23 17:10:01 +00:00
Some minor cleanups in the PNGLibrary class.
The UNIX builds for Debian and Redhat/RPM now default to using the builtin PNG and zlib libraries. This will ease issues at release time, since we don't need to worry about those libraries being present on the destination systems. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2054 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
ad83d21a69
commit
5099e2d9fc
2
debian/rules
vendored
2
debian/rules
vendored
@ -20,7 +20,7 @@ endif
|
||||
|
||||
config.status: configure
|
||||
dh_testdir
|
||||
CXXFLAGS="$(CXXFLAGS)" ./configure --prefix=/usr
|
||||
CXXFLAGS="$(CXXFLAGS)" ./configure --prefix=/usr --force-builtin-libpng --force-builtin-zlib
|
||||
|
||||
build: build-stamp
|
||||
|
||||
|
@ -37,7 +37,7 @@ PNGLibrary::~PNGLibrary()
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PNGLibrary::readImage(const FrameBuffer& fb, FBSurface& surface)
|
||||
{
|
||||
#define readImageERROR(s) { err_message = s; goto error; }
|
||||
#define readImageERROR(s) { err_message = s; goto done; }
|
||||
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
@ -45,22 +45,22 @@ bool PNGLibrary::readImage(const FrameBuffer& fb, FBSurface& surface)
|
||||
png_uint_32 iwidth, iheight, ipitch;
|
||||
uInt8* buffer = NULL;
|
||||
int bit_depth, color_type, interlace_type;
|
||||
const char* err_message;
|
||||
const char* err_message = NULL;
|
||||
|
||||
ifstream* in = new ifstream(myFilename.c_str(), ios_base::binary);
|
||||
if(!in || !in->is_open())
|
||||
readImageERROR("No image found")
|
||||
readImageERROR("No image found");
|
||||
|
||||
// Create the PNG loading context structure
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||
png_user_error, png_user_warn);
|
||||
if(png_ptr == NULL)
|
||||
readImageERROR("Couldn't allocate memory for PNG file")
|
||||
readImageERROR("Couldn't allocate memory for PNG file");
|
||||
|
||||
// Allocate/initialize the memory for image information. REQUIRED.
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if(info_ptr == NULL)
|
||||
readImageERROR("Couldn't create image information for PNG file")
|
||||
readImageERROR("Couldn't create image information for PNG file");
|
||||
|
||||
// Set up the input control
|
||||
png_set_read_fn(png_ptr, in, png_read_data);
|
||||
@ -79,13 +79,13 @@ bool PNGLibrary::readImage(const FrameBuffer& fb, FBSurface& surface)
|
||||
|
||||
// Greyscale mode not supported
|
||||
if(color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
readImageERROR("Greyscale PNG images not supported")
|
||||
readImageERROR("Greyscale PNG images not supported");
|
||||
|
||||
// Create space for the entire image (3 bytes per pixel in RGB format)
|
||||
ipitch = iwidth * 3;
|
||||
buffer = new uInt8[ipitch * iheight];
|
||||
if(buffer == NULL)
|
||||
readImageERROR("Not enough memory to read PNG file")
|
||||
readImageERROR("Not enough memory to read PNG file");
|
||||
|
||||
// The PNG read function expects an array of rows, not a single 1-D array
|
||||
row_pointers = new png_bytep[iheight];
|
||||
@ -103,22 +103,17 @@ bool PNGLibrary::readImage(const FrameBuffer& fb, FBSurface& surface)
|
||||
scaleImagetoSurface(iwidth, iheight, buffer, fb, surface);
|
||||
|
||||
// Cleanup
|
||||
done:
|
||||
if(png_ptr)
|
||||
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : (png_infopp)0, (png_infopp)0);
|
||||
if(in)
|
||||
in->close();
|
||||
delete[] buffer;
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
if(png_ptr)
|
||||
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : (png_infopp)0, (png_infopp)0);
|
||||
if(in)
|
||||
in->close();
|
||||
delete[] buffer;
|
||||
|
||||
throw err_message;
|
||||
if(err_message)
|
||||
throw err_message;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -20,7 +20,7 @@ License: GPL
|
||||
URL: http://stella.sourceforge.net
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
BuildRoot: %_tmppath/%name-%version-%release-root
|
||||
BuildRequires: SDL-devel MesaGLU-devel zlib-devel
|
||||
BuildRequires: SDL-devel MesaGLU-devel
|
||||
|
||||
%description
|
||||
The Atari 2600 Video Computer System (VCS), introduced in 1977, was the most
|
||||
@ -65,6 +65,7 @@ export CXXFLAGS=$RPM_OPT_FLAGS
|
||||
%else
|
||||
--enable-shared \
|
||||
%endif
|
||||
--force-builtin-libpng --force-builtin-zlib \
|
||||
--docdir=%{_docdir}/stella \
|
||||
--x-libraries=%{_prefix}/X11R6/%{_lib}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user