mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.2.0beta4.tar
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
|
||||
# Greg Roelofs
|
||||
# Last modified: 28 February 2000
|
||||
# Last modified: 7 February 2001
|
||||
#
|
||||
# The programs built by this makefile are described in the book,
|
||||
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
|
||||
@@ -27,20 +27,20 @@ PNGINC = -I/usr/local/include
|
||||
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
|
||||
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
#PNGLIB = ../../libpng.a
|
||||
#PNGINC = -I../libpng
|
||||
#PNGLIB = -L../libpng -lpng
|
||||
#PNGLIB = ../libpng/libpng.a
|
||||
|
||||
ZINC = -I/usr/local/include
|
||||
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
|
||||
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
|
||||
#ZINC = -I../zlib
|
||||
#ZLIB = -L../zlib -lz
|
||||
#ZLIB = ../../../zlib/libz.a
|
||||
#ZLIB = ../zlib/libz.a
|
||||
|
||||
#XINC = -I/usr/include/X11 # old-style, stock X distributions
|
||||
#XINC = -I/usr/include # old-style, stock X distributions
|
||||
#XLIB = -L/usr/lib/X11 -lX11
|
||||
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
|
||||
#XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
|
||||
#XLIB = -L/usr/openwin/lib -lX11
|
||||
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
|
||||
XLIB = -L/usr/X11R6/lib -lX11
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGPATH = ../..
|
||||
PNGPATH = ../libpng
|
||||
PNGINC = -I$(PNGPATH)
|
||||
#PNGLIB = $(PNGPATH)/pngdll.lib
|
||||
PNGLIB = $(PNGPATH)/libpng.lib
|
||||
|
||||
ZPATH = ../../../zlib
|
||||
ZPATH = ../zlib
|
||||
ZINC = -I$(ZPATH)
|
||||
#ZLIB = $(ZPATH)/zlibdll.lib
|
||||
ZLIB = $(ZPATH)/zlibstat.lib
|
||||
|
||||
@@ -16,13 +16,12 @@ of PBMPLUS/NetPBM) and converts them to PNG.
|
||||
The source code for all three demo programs currently compiles under
|
||||
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
||||
providing an appropriate build script.) Build instructions can be
|
||||
found below.
|
||||
providing an appropriate build script.) Build instructions can be found
|
||||
below.
|
||||
|
||||
Files:
|
||||
|
||||
README this file
|
||||
README.w32 additional Windows-specific information
|
||||
LICENSE terms of distribution and reuse (BSD-like)
|
||||
|
||||
Makefile.unx Unix makefile
|
||||
@@ -46,25 +45,26 @@ Files:
|
||||
toucan.png transparent PNG for testing (by Stefan Schneider)
|
||||
|
||||
Note that the programs are designed to be functional, but their primary
|
||||
purpose is to demonstrate how to use libpng to add PNG support to other
|
||||
purpose is to illustrate how to use libpng to add PNG support to other
|
||||
programs. As such, their user interfaces are crude and definitely not
|
||||
intended for everyday use.
|
||||
|
||||
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor-
|
||||
Please see http://www.libpng.org/pub/png/pngbook.html for further infor-
|
||||
mation and links to the latest version of the source code, and Chapters
|
||||
13-15 of the book for detailed discussion of the three programs.
|
||||
|
||||
Greg Roelofs
|
||||
19 March 2000
|
||||
newt@pobox.com
|
||||
30 May 2001
|
||||
|
||||
|
||||
BUILD INSTRUCTIONS
|
||||
|
||||
- Prerequisites:
|
||||
- Prerequisites (in order of compilation):
|
||||
|
||||
- zlib ftp://ftp.cdrom.com/pub/infozip/zlib/zlib.html
|
||||
- libpng http://www.cdrom.com/pub/png/pngcode.html
|
||||
- pngbook http://www.cdrom.com/pub/png/book/sources.html
|
||||
- zlib http://www.gzip.org/zlib/
|
||||
- libpng http://www.libpng.org/pub/png/libpng.html
|
||||
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
||||
|
||||
The pngbook demo programs are explicitly designed to demonstrate proper
|
||||
coding techniques for using the libpng reference library. As a result,
|
||||
@@ -128,11 +128,13 @@ BUILD INSTRUCTIONS
|
||||
|
||||
The result should be three executables: rpng-win.exe, rpng2-win.exe,
|
||||
and wpng.exe. Copy them somewhere in your PATH or run them from the
|
||||
current folder. Unlike the Unix versions, the two windowed programs
|
||||
(rpng and rpng2) do not display a usage screen when invoked without
|
||||
command-line arguments; see README.w32 for brief help or the book for
|
||||
details. Note that the programs use the Unix-style "-" character to
|
||||
specify options, instead of the more common DOS/Windows "/" character.
|
||||
current folder. Like the Unix versions, the two windowed programs
|
||||
(rpng and rpng2) now display a usage screen in a console window when
|
||||
invoked without command-line arguments; this is new behavior as of
|
||||
the May 2001 release. Note that the programs use the Unix-style "-"
|
||||
character to specify options, instead of the more common DOS/Windows
|
||||
"/" character. (For example: "rpng2-win -bgpat 4 foo.png", not
|
||||
"rpng2-win /bgpat 4 foo.png")
|
||||
|
||||
|
||||
- OpenVMS:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
See the main README file for basic instructions on compiling and running
|
||||
the programs. See http://www.cdrom.com/pub/png/pngbook.html for further
|
||||
the programs. See http://www.libpng.org/pub/png/pngbook.html for further
|
||||
information and links to the source code, and Chapters 13-15 of the book
|
||||
for detailed discussion of the three programs.
|
||||
|
||||
|
||||
@@ -9,21 +9,22 @@ $! Set locations where zlib and libpng sources live.
|
||||
$!
|
||||
$ zpath = ""
|
||||
$ pngpath = ""
|
||||
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
|
||||
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
|
||||
$!
|
||||
$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]"
|
||||
$ if f$search("[--]png.h").nes."" then pngpath = "[--]"
|
||||
$!
|
||||
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
|
||||
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
|
||||
$!
|
||||
$ if zpath .eqs. ""
|
||||
$ then
|
||||
$ write sys$output "Zlib include not found. Exiting..."
|
||||
$ write sys$output "zlib include not found. Exiting..."
|
||||
$ exit 2
|
||||
$ endif
|
||||
$!
|
||||
$ if pngpath .eqs. ""
|
||||
$ then
|
||||
$ write sys$output "Libpng include not found. Exiting..."
|
||||
$ write sys$output "libpng include not found. Exiting..."
|
||||
$ exit 2
|
||||
$ endif
|
||||
$!
|
||||
|
||||
@@ -239,7 +239,7 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
|
||||
Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height));
|
||||
|
||||
|
||||
/* set the individual row_pointers to point at the correct offsets */
|
||||
|
||||
@@ -117,8 +117,8 @@ void readpng2_version_info(void)
|
||||
}
|
||||
}
|
||||
#else
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
|
||||
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
|
||||
"without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
|
||||
@@ -530,7 +530,6 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
(*mainprog_ptr->mainprog_finish_display)();
|
||||
|
||||
info_ptr = info_ptr; /* without this the compiler whines about info_ptr */
|
||||
|
||||
/* all done */
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
with a little tweaking (or maybe not).
|
||||
|
||||
to do:
|
||||
- stdout/stderr don't work! need message window (maybe scrollable?)
|
||||
- handle quoted command-line args (especially filenames with spaces)
|
||||
- have minimum window width: oh well
|
||||
- use %.1023s to simplify truncation of title-bar string?
|
||||
@@ -22,10 +21,11 @@
|
||||
match; switched to png_jmpbuf() macro
|
||||
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -52,13 +52,14 @@
|
||||
|
||||
#define PROGNAME "rpng-win"
|
||||
#define LONGNAME "Simple PNG Viewer for Windows"
|
||||
#define VERSION "1.02 of 19 March 2000"
|
||||
#define VERSION "1.20 of 28 May 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
#include <conio.h> /* only for _getch() */
|
||||
|
||||
/* #define DEBUG : this enables the Trace() macros */
|
||||
|
||||
@@ -128,7 +129,17 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
filename = (char *)NULL;
|
||||
|
||||
|
||||
/* First set the default value for our display-system exponent, i.e.,
|
||||
/* First reenable console output, which normally goes to the bit bucket
|
||||
* for windowed apps. Closing the console window will terminate the
|
||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
||||
* incantation. */
|
||||
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "a", stderr);
|
||||
freopen("CONOUT$", "a", stdout);
|
||||
|
||||
|
||||
/* Next set the default value for our display-system exponent, i.e.,
|
||||
* the product of the CRT exponent and the exponent corresponding to
|
||||
* the frame-buffer's lookup table (LUT), if any. This is not an
|
||||
* exhaustive list of LUT values (e.g., OpenStep has a lot of weird
|
||||
@@ -272,20 +283,31 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||
/* usage screen */
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
int ch;
|
||||
|
||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||
readpng_version_info();
|
||||
fprintf(stderr, "\n"
|
||||
"Usage: %s [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
"Usage: %s [-gamma exp] [-bgcolor bg] file.png\n"
|
||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||
"\t\t used with transparent images\n"
|
||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||
"Press Q or Esc to quit this usage screen.\n"
|
||||
"\n", PROGNAME, default_display_exponent);
|
||||
do
|
||||
ch = _getch();
|
||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||
exit(1);
|
||||
} else {
|
||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||
fprintf(stderr,
|
||||
"\n [console window: closing this window will terminate %s]\n\n",
|
||||
PROGNAME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
- 1.12: fixed small X memory leak (thanks to Francois Petitjean)
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
|
||||
Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
|
||||
|
||||
This software is provided "as is," without warranty of any kind,
|
||||
express or implied. In no event shall the author or contributors
|
||||
@@ -51,7 +52,7 @@
|
||||
|
||||
#define PROGNAME "rpng-x"
|
||||
#define LONGNAME "Simple PNG Viewer for X"
|
||||
#define VERSION "1.11 of 19 March 2000"
|
||||
#define VERSION "1.12 of 28 May 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -542,6 +543,16 @@ static int rpng_x_create_window(void)
|
||||
XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0,
|
||||
size_hints, wm_hints, NULL);
|
||||
|
||||
/* various properties and hints no longer needed; free memory */
|
||||
if (pWindowName)
|
||||
XFree(pWindowName->value);
|
||||
if (pIconName)
|
||||
XFree(pIconName->value);
|
||||
if (size_hints)
|
||||
XFree(size_hints);
|
||||
if (wm_hints)
|
||||
XFree(wm_hints);
|
||||
|
||||
XMapWindow(display, window);
|
||||
|
||||
gc = XCreateGC(display, window, 0, &gcvalues);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
- 1.03: modified to allow abbreviated options
|
||||
- 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?];
|
||||
fixed command-line parsing bug
|
||||
- 1.10: enabled "message window" (console), thanks to David Geldreich
|
||||
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
||||
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
#define PROGNAME "rpng2-win"
|
||||
#define LONGNAME "Progressive PNG Viewer for Windows"
|
||||
#define VERSION "1.20 of 29 January 2001"
|
||||
#define VERSION "1.20 of 28 May 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
- 1.11: added -usleep option for demos; fixed command-line parsing bug
|
||||
- 1.12: added -pause option for demos and testing
|
||||
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options
|
||||
- 1.21: fixed small X memory leak (thanks to Francois Petitjean)
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
@@ -56,7 +57,7 @@
|
||||
|
||||
#define PROGNAME "rpng2-x"
|
||||
#define LONGNAME "Progressive PNG Viewer for X"
|
||||
#define VERSION "1.20 of 29 January 2001"
|
||||
#define VERSION "1.21 of 30 May 2001"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -585,8 +586,15 @@ static void rpng2_x_init(void)
|
||||
* pattern */
|
||||
|
||||
if (rpng2_x_create_window()) {
|
||||
|
||||
/* GRR TEMPORARY HACK: this is fundamentally no different from cases
|
||||
* above; libpng should longjmp() back to us when png_ptr goes away.
|
||||
* If we/it segfault instead, seems like a libpng bug... */
|
||||
|
||||
/* we're here via libpng callback, so if window fails, clean and bail */
|
||||
readpng2_cleanup(&rpng2_info);
|
||||
return;
|
||||
rpng2_x_cleanup();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,6 +746,16 @@ static int rpng2_x_create_window(void)
|
||||
XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0,
|
||||
size_hints, wm_hints, NULL);
|
||||
|
||||
/* various properties and hints no longer needed; free memory */
|
||||
if (pWindowName)
|
||||
XFree(pWindowName->value);
|
||||
if (pIconName)
|
||||
XFree(pIconName->value);
|
||||
if (size_hints)
|
||||
XFree(size_hints);
|
||||
if (wm_hints)
|
||||
XFree(wm_hints);
|
||||
|
||||
XMapWindow(display, window);
|
||||
|
||||
gc = XCreateGC(display, window, 0, &gcvalues);
|
||||
|
||||
Reference in New Issue
Block a user