mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
use lodepng for screenshots
This commit is contained in:
parent
68c01e2be3
commit
45ceb74df2
8
Makefile
8
Makefile
@ -1,10 +1,7 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
WINDRES=windres
|
WINDRES=windres
|
||||||
CFLAGS=-DHAVE_LIBPNG -Iinc -Wall -Wl,--enable-stdcall-fixup -s
|
CFLAGS=-Iinc -Wall -Wl,--enable-stdcall-fixup -s
|
||||||
LIBS=lib/libpng14.a lib/libz.a -lgdi32 -lwinmm
|
LIBS=-lgdi32 -lwinmm
|
||||||
|
|
||||||
#CFLAGS=-Iinc -Wall -Wl,--enable-stdcall-fixup -O3 -s
|
|
||||||
#LIBS=-lgdi32 -lwinmm
|
|
||||||
|
|
||||||
FILES = src/debug.c \
|
FILES = src/debug.c \
|
||||||
src/main.c \
|
src/main.c \
|
||||||
@ -17,6 +14,7 @@ FILES = src/debug.c \
|
|||||||
src/render_d3d9.c \
|
src/render_d3d9.c \
|
||||||
src/screenshot.c \
|
src/screenshot.c \
|
||||||
src/settings.c \
|
src/settings.c \
|
||||||
|
src/lodepng.c \
|
||||||
src/opengl.c
|
src/opengl.c
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\clipper.c" />
|
<ClCompile Include="src\clipper.c" />
|
||||||
<ClCompile Include="src\debug.c" />
|
<ClCompile Include="src\debug.c" />
|
||||||
|
<ClCompile Include="src\lodepng.c" />
|
||||||
<ClCompile Include="src\main.c" />
|
<ClCompile Include="src\main.c" />
|
||||||
<ClCompile Include="src\mouse.c" />
|
<ClCompile Include="src\mouse.c" />
|
||||||
<ClCompile Include="src\opengl.c" />
|
<ClCompile Include="src\opengl.c" />
|
||||||
@ -28,6 +29,7 @@
|
|||||||
<ClInclude Include="inc\clipper.h" />
|
<ClInclude Include="inc\clipper.h" />
|
||||||
<ClInclude Include="inc\glcorearb.h" />
|
<ClInclude Include="inc\glcorearb.h" />
|
||||||
<ClInclude Include="inc\KHR\khrplatform.h" />
|
<ClInclude Include="inc\KHR\khrplatform.h" />
|
||||||
|
<ClInclude Include="inc\lodepng.h" />
|
||||||
<ClInclude Include="inc\render_d3d9.h" />
|
<ClInclude Include="inc\render_d3d9.h" />
|
||||||
<ClInclude Include="inc\ddraw.h" />
|
<ClInclude Include="inc\ddraw.h" />
|
||||||
<ClInclude Include="inc\debug.h" />
|
<ClInclude Include="inc\debug.h" />
|
||||||
@ -36,11 +38,7 @@
|
|||||||
<ClInclude Include="inc\palette.h" />
|
<ClInclude Include="inc\palette.h" />
|
||||||
<ClInclude Include="inc\openglshader.h" />
|
<ClInclude Include="inc\openglshader.h" />
|
||||||
<ClInclude Include="inc\d3d9shader.h" />
|
<ClInclude Include="inc\d3d9shader.h" />
|
||||||
<ClInclude Include="inc\png.h" />
|
|
||||||
<ClInclude Include="inc\pngconf.h" />
|
|
||||||
<ClInclude Include="inc\surface.h" />
|
<ClInclude Include="inc\surface.h" />
|
||||||
<ClInclude Include="inc\zconf.h" />
|
|
||||||
<ClInclude Include="inc\zlib.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="ddraw.rc" />
|
<ResourceCompile Include="ddraw.rc" />
|
||||||
|
@ -51,6 +51,9 @@
|
|||||||
<ClCompile Include="src\settings.c">
|
<ClCompile Include="src\settings.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\lodepng.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="inc\clipper.h">
|
<ClInclude Include="inc\clipper.h">
|
||||||
@ -68,21 +71,9 @@
|
|||||||
<ClInclude Include="inc\palette.h">
|
<ClInclude Include="inc\palette.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="inc\png.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="inc\pngconf.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="inc\surface.h">
|
<ClInclude Include="inc\surface.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="inc\zconf.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="inc\zlib.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="inc\opengl.h">
|
<ClInclude Include="inc\opengl.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@ -101,6 +92,9 @@
|
|||||||
<ClInclude Include="inc\KHR\khrplatform.h">
|
<ClInclude Include="inc\KHR\khrplatform.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="inc\lodepng.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="ddraw.rc">
|
<ResourceCompile Include="ddraw.rc">
|
||||||
|
2
ddraw.rc
2
ddraw.rc
@ -4,7 +4,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_BUILD 4
|
#define VERSION_BUILD 4
|
||||||
#define VERSION_REVISION 2
|
#define VERSION_REVISION 3
|
||||||
|
|
||||||
#define VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION
|
#define VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION
|
||||||
#define VERSION_STRING ver_str(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION)
|
#define VERSION_STRING ver_str(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION)
|
||||||
|
1924
inc/lodepng.h
Normal file
1924
inc/lodepng.h
Normal file
File diff suppressed because it is too large
Load Diff
1540
inc/pngconf.h
1540
inc/pngconf.h
File diff suppressed because it is too large
Load Diff
428
inc/zconf.h
428
inc/zconf.h
@ -1,428 +0,0 @@
|
|||||||
/* zconf.h -- configuration of the zlib compression library
|
|
||||||
* Copyright (C) 1995-2010 Jean-loup Gailly.
|
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
|
||||||
|
|
||||||
#ifndef ZCONF_H
|
|
||||||
#define ZCONF_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
|
||||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
|
||||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
|
||||||
* this permanently in zconf.h using "./configure --zprefix".
|
|
||||||
*/
|
|
||||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
|
||||||
|
|
||||||
/* all linked symbols */
|
|
||||||
# define _dist_code z__dist_code
|
|
||||||
# define _length_code z__length_code
|
|
||||||
# define _tr_align z__tr_align
|
|
||||||
# define _tr_flush_block z__tr_flush_block
|
|
||||||
# define _tr_init z__tr_init
|
|
||||||
# define _tr_stored_block z__tr_stored_block
|
|
||||||
# define _tr_tally z__tr_tally
|
|
||||||
# define adler32 z_adler32
|
|
||||||
# define adler32_combine z_adler32_combine
|
|
||||||
# define adler32_combine64 z_adler32_combine64
|
|
||||||
# define compress z_compress
|
|
||||||
# define compress2 z_compress2
|
|
||||||
# define compressBound z_compressBound
|
|
||||||
# define crc32 z_crc32
|
|
||||||
# define crc32_combine z_crc32_combine
|
|
||||||
# define crc32_combine64 z_crc32_combine64
|
|
||||||
# define deflate z_deflate
|
|
||||||
# define deflateBound z_deflateBound
|
|
||||||
# define deflateCopy z_deflateCopy
|
|
||||||
# define deflateEnd z_deflateEnd
|
|
||||||
# define deflateInit2_ z_deflateInit2_
|
|
||||||
# define deflateInit_ z_deflateInit_
|
|
||||||
# define deflateParams z_deflateParams
|
|
||||||
# define deflatePrime z_deflatePrime
|
|
||||||
# define deflateReset z_deflateReset
|
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
|
||||||
# define deflateSetHeader z_deflateSetHeader
|
|
||||||
# define deflateTune z_deflateTune
|
|
||||||
# define deflate_copyright z_deflate_copyright
|
|
||||||
# define get_crc_table z_get_crc_table
|
|
||||||
# define gz_error z_gz_error
|
|
||||||
# define gz_intmax z_gz_intmax
|
|
||||||
# define gz_strwinerror z_gz_strwinerror
|
|
||||||
# define gzbuffer z_gzbuffer
|
|
||||||
# define gzclearerr z_gzclearerr
|
|
||||||
# define gzclose z_gzclose
|
|
||||||
# define gzclose_r z_gzclose_r
|
|
||||||
# define gzclose_w z_gzclose_w
|
|
||||||
# define gzdirect z_gzdirect
|
|
||||||
# define gzdopen z_gzdopen
|
|
||||||
# define gzeof z_gzeof
|
|
||||||
# define gzerror z_gzerror
|
|
||||||
# define gzflush z_gzflush
|
|
||||||
# define gzgetc z_gzgetc
|
|
||||||
# define gzgets z_gzgets
|
|
||||||
# define gzoffset z_gzoffset
|
|
||||||
# define gzoffset64 z_gzoffset64
|
|
||||||
# define gzopen z_gzopen
|
|
||||||
# define gzopen64 z_gzopen64
|
|
||||||
# define gzprintf z_gzprintf
|
|
||||||
# define gzputc z_gzputc
|
|
||||||
# define gzputs z_gzputs
|
|
||||||
# define gzread z_gzread
|
|
||||||
# define gzrewind z_gzrewind
|
|
||||||
# define gzseek z_gzseek
|
|
||||||
# define gzseek64 z_gzseek64
|
|
||||||
# define gzsetparams z_gzsetparams
|
|
||||||
# define gztell z_gztell
|
|
||||||
# define gztell64 z_gztell64
|
|
||||||
# define gzungetc z_gzungetc
|
|
||||||
# define gzwrite z_gzwrite
|
|
||||||
# define inflate z_inflate
|
|
||||||
# define inflateBack z_inflateBack
|
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
|
||||||
# define inflateBackInit_ z_inflateBackInit_
|
|
||||||
# define inflateCopy z_inflateCopy
|
|
||||||
# define inflateEnd z_inflateEnd
|
|
||||||
# define inflateGetHeader z_inflateGetHeader
|
|
||||||
# define inflateInit2_ z_inflateInit2_
|
|
||||||
# define inflateInit_ z_inflateInit_
|
|
||||||
# define inflateMark z_inflateMark
|
|
||||||
# define inflatePrime z_inflatePrime
|
|
||||||
# define inflateReset z_inflateReset
|
|
||||||
# define inflateReset2 z_inflateReset2
|
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
|
||||||
# define inflateSync z_inflateSync
|
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
|
||||||
# define inflateUndermine z_inflateUndermine
|
|
||||||
# define inflate_copyright z_inflate_copyright
|
|
||||||
# define inflate_fast z_inflate_fast
|
|
||||||
# define inflate_table z_inflate_table
|
|
||||||
# define uncompress z_uncompress
|
|
||||||
# define zError z_zError
|
|
||||||
# define zcalloc z_zcalloc
|
|
||||||
# define zcfree z_zcfree
|
|
||||||
# define zlibCompileFlags z_zlibCompileFlags
|
|
||||||
# define zlibVersion z_zlibVersion
|
|
||||||
|
|
||||||
/* all zlib typedefs in zlib.h and zconf.h */
|
|
||||||
# define Byte z_Byte
|
|
||||||
# define Bytef z_Bytef
|
|
||||||
# define alloc_func z_alloc_func
|
|
||||||
# define charf z_charf
|
|
||||||
# define free_func z_free_func
|
|
||||||
# define gzFile z_gzFile
|
|
||||||
# define gz_header z_gz_header
|
|
||||||
# define gz_headerp z_gz_headerp
|
|
||||||
# define in_func z_in_func
|
|
||||||
# define intf z_intf
|
|
||||||
# define out_func z_out_func
|
|
||||||
# define uInt z_uInt
|
|
||||||
# define uIntf z_uIntf
|
|
||||||
# define uLong z_uLong
|
|
||||||
# define uLongf z_uLongf
|
|
||||||
# define voidp z_voidp
|
|
||||||
# define voidpc z_voidpc
|
|
||||||
# define voidpf z_voidpf
|
|
||||||
|
|
||||||
/* all zlib structs in zlib.h and zconf.h */
|
|
||||||
# define gz_header_s z_gz_header_s
|
|
||||||
# define internal_state z_internal_state
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
|
||||||
# define MSDOS
|
|
||||||
#endif
|
|
||||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
|
||||||
# define OS2
|
|
||||||
#endif
|
|
||||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
|
||||||
# define WINDOWS
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
|
||||||
# ifndef WIN32
|
|
||||||
# define WIN32
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
|
||||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
|
||||||
# ifndef SYS16BIT
|
|
||||||
# define SYS16BIT
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
|
||||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
|
||||||
*/
|
|
||||||
#ifdef SYS16BIT
|
|
||||||
# define MAXSEG_64K
|
|
||||||
#endif
|
|
||||||
#ifdef MSDOS
|
|
||||||
# define UNALIGNED_OK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __STDC_VERSION__
|
|
||||||
# ifndef STDC
|
|
||||||
# define STDC
|
|
||||||
# endif
|
|
||||||
# if __STDC_VERSION__ >= 199901L
|
|
||||||
# ifndef STDC99
|
|
||||||
# define STDC99
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STDC
|
|
||||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
|
||||||
# define const /* note: need a more gentle solution here */
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Some Mac compilers merge all .h files incorrectly: */
|
|
||||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
|
||||||
# define NO_DUMMY_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Maximum value for memLevel in deflateInit2 */
|
|
||||||
#ifndef MAX_MEM_LEVEL
|
|
||||||
# ifdef MAXSEG_64K
|
|
||||||
# define MAX_MEM_LEVEL 8
|
|
||||||
# else
|
|
||||||
# define MAX_MEM_LEVEL 9
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
|
||||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
|
||||||
* created by gzip. (Files created by minigzip can still be extracted by
|
|
||||||
* gzip.)
|
|
||||||
*/
|
|
||||||
#ifndef MAX_WBITS
|
|
||||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The memory requirements for deflate are (in bytes):
|
|
||||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
|
||||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
|
||||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
|
||||||
the default memory requirements from 256K to 128K, compile with
|
|
||||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
|
||||||
Of course this will generally degrade compression (there's no free lunch).
|
|
||||||
|
|
||||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
|
||||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
|
||||||
for small objects.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Type declarations */
|
|
||||||
|
|
||||||
#ifndef OF /* function prototypes */
|
|
||||||
# ifdef STDC
|
|
||||||
# define OF(args) args
|
|
||||||
# else
|
|
||||||
# define OF(args) ()
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
|
||||||
* model programming (small or medium model with some far allocations).
|
|
||||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
|
||||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
|
||||||
* just define FAR to be empty.
|
|
||||||
*/
|
|
||||||
#ifdef SYS16BIT
|
|
||||||
# if defined(M_I86SM) || defined(M_I86MM)
|
|
||||||
/* MSC small or medium model */
|
|
||||||
# define SMALL_MEDIUM
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# define FAR _far
|
|
||||||
# else
|
|
||||||
# define FAR far
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
|
||||||
/* Turbo C small or medium model */
|
|
||||||
# define SMALL_MEDIUM
|
|
||||||
# ifdef __BORLANDC__
|
|
||||||
# define FAR _far
|
|
||||||
# else
|
|
||||||
# define FAR far
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(WIN32)
|
|
||||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
|
||||||
* This is not mandatory, but it offers a little performance increase.
|
|
||||||
*/
|
|
||||||
# ifdef ZLIB_DLL
|
|
||||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
|
||||||
# ifdef ZLIB_INTERNAL
|
|
||||||
# define ZEXTERN extern __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define ZEXTERN extern __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif /* ZLIB_DLL */
|
|
||||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
|
||||||
* define ZLIB_WINAPI.
|
|
||||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
|
||||||
*/
|
|
||||||
# ifdef ZLIB_WINAPI
|
|
||||||
# ifdef FAR
|
|
||||||
# undef FAR
|
|
||||||
# endif
|
|
||||||
# include <windows.h>
|
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
|
||||||
# define ZEXPORT WINAPI
|
|
||||||
# ifdef WIN32
|
|
||||||
# define ZEXPORTVA WINAPIV
|
|
||||||
# else
|
|
||||||
# define ZEXPORTVA FAR CDECL
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (__BEOS__)
|
|
||||||
# ifdef ZLIB_DLL
|
|
||||||
# ifdef ZLIB_INTERNAL
|
|
||||||
# define ZEXPORT __declspec(dllexport)
|
|
||||||
# define ZEXPORTVA __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define ZEXPORT __declspec(dllimport)
|
|
||||||
# define ZEXPORTVA __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ZEXTERN
|
|
||||||
# define ZEXTERN extern
|
|
||||||
#endif
|
|
||||||
#ifndef ZEXPORT
|
|
||||||
# define ZEXPORT
|
|
||||||
#endif
|
|
||||||
#ifndef ZEXPORTVA
|
|
||||||
# define ZEXPORTVA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FAR
|
|
||||||
# define FAR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__MACTYPES__)
|
|
||||||
typedef unsigned char Byte; /* 8 bits */
|
|
||||||
#endif
|
|
||||||
typedef unsigned int uInt; /* 16 bits or more */
|
|
||||||
typedef unsigned long uLong; /* 32 bits or more */
|
|
||||||
|
|
||||||
#ifdef SMALL_MEDIUM
|
|
||||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
|
||||||
# define Bytef Byte FAR
|
|
||||||
#else
|
|
||||||
typedef Byte FAR Bytef;
|
|
||||||
#endif
|
|
||||||
typedef char FAR charf;
|
|
||||||
typedef int FAR intf;
|
|
||||||
typedef uInt FAR uIntf;
|
|
||||||
typedef uLong FAR uLongf;
|
|
||||||
|
|
||||||
#ifdef STDC
|
|
||||||
typedef void const *voidpc;
|
|
||||||
typedef void FAR *voidpf;
|
|
||||||
typedef void *voidp;
|
|
||||||
#else
|
|
||||||
typedef Byte const *voidpc;
|
|
||||||
typedef Byte FAR *voidpf;
|
|
||||||
typedef Byte *voidp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 1 /* was set to #if 1 by ./configure */
|
|
||||||
# define Z_HAVE_UNISTD_H
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef STDC
|
|
||||||
# include <sys/types.h> /* for off_t */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
|
||||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
|
||||||
* though the former does not conform to the LFS document), but considering
|
|
||||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
|
||||||
* equivalently requesting no 64-bit operations
|
|
||||||
*/
|
|
||||||
#if -_LARGEFILE64_SOURCE - -1 == 1
|
|
||||||
# undef _LARGEFILE64_SOURCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
|
||||||
# ifdef VMS
|
|
||||||
# include <unixio.h> /* for off_t */
|
|
||||||
# endif
|
|
||||||
# ifndef z_off_t
|
|
||||||
# define z_off_t off_t
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SEEK_SET
|
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
|
||||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef z_off_t
|
|
||||||
# define z_off_t long
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
|
||||||
# define z_off64_t off64_t
|
|
||||||
#else
|
|
||||||
# define z_off64_t z_off_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__OS400__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MVS__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
|
||||||
#if defined(__MVS__)
|
|
||||||
#pragma map(deflateInit_,"DEIN")
|
|
||||||
#pragma map(deflateInit2_,"DEIN2")
|
|
||||||
#pragma map(deflateEnd,"DEEND")
|
|
||||||
#pragma map(deflateBound,"DEBND")
|
|
||||||
#pragma map(inflateInit_,"ININ")
|
|
||||||
#pragma map(inflateInit2_,"ININ2")
|
|
||||||
#pragma map(inflateEnd,"INEND")
|
|
||||||
#pragma map(inflateSync,"INSY")
|
|
||||||
#pragma map(inflateSetDictionary,"INSEDI")
|
|
||||||
#pragma map(compressBound,"CMBND")
|
|
||||||
#pragma map(inflate_table,"INTABL")
|
|
||||||
#pragma map(inflate_fast,"INFA")
|
|
||||||
#pragma map(inflate_copyright,"INCOPY")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ZCONF_H */
|
|
1613
inc/zlib.h
1613
inc/zlib.h
File diff suppressed because it is too large
Load Diff
BIN
lib/libpng14.a
BIN
lib/libpng14.a
Binary file not shown.
BIN
lib/libz.a
BIN
lib/libz.a
Binary file not shown.
6853
src/lodepng.c
Normal file
6853
src/lodepng.c
Normal file
File diff suppressed because it is too large
Load Diff
171
src/screenshot.c
171
src/screenshot.c
@ -16,31 +16,22 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <time.h>
|
||||||
#include "ddraw.h"
|
#include "ddraw.h"
|
||||||
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "surface.h"
|
#include "surface.h"
|
||||||
|
#include "lodepng.h"
|
||||||
#ifndef HAVE_LIBPNG
|
|
||||||
|
|
||||||
//https://docs.microsoft.com/en-us/windows/desktop/gdi/storing-an-image
|
|
||||||
|
|
||||||
BOOL screenshot(struct IDirectDrawSurfaceImpl *src)
|
BOOL screenshot(struct IDirectDrawSurfaceImpl *src)
|
||||||
{
|
{
|
||||||
HANDLE hf; // file handle
|
if (!src || !src->palette || !src->surface)
|
||||||
BITMAPFILEHEADER hdr; // bitmap file-header
|
return FALSE;
|
||||||
PBITMAPINFOHEADER pbih; // bitmap info-header
|
|
||||||
LPBYTE lpBits; // memory pointer
|
|
||||||
DWORD dwTotal; // total count of bytes
|
|
||||||
DWORD cb; // incremental count of bytes
|
|
||||||
BYTE *hp; // byte pointer
|
|
||||||
DWORD dwTmp;
|
|
||||||
int i;
|
int i;
|
||||||
char title[128];
|
char title[128];
|
||||||
char filename[128];
|
char filename[128];
|
||||||
char str_time[64];
|
char str_time[64];
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
BOOL result = TRUE;
|
|
||||||
|
|
||||||
strncpy(title, ddraw->title, sizeof(ddraw->title));
|
strncpy(title, ddraw->title, sizeof(ddraw->title));
|
||||||
|
|
||||||
@ -55,145 +46,33 @@ BOOL screenshot(struct IDirectDrawSurfaceImpl *src)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strftime(str_time, 64, "%Y-%m-%d-%H_%M_%S", localtime(&t));
|
|
||||||
_snprintf(filename, 128, "%s-%s.bmp", title, str_time);
|
|
||||||
|
|
||||||
pbih = (PBITMAPINFOHEADER)src->bmi;
|
|
||||||
lpBits = (LPBYTE)src->surface;
|
|
||||||
|
|
||||||
if (!lpBits)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// Create the .BMP file.
|
|
||||||
hf = CreateFile(filename,
|
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
|
||||||
(DWORD)0,
|
|
||||||
NULL,
|
|
||||||
CREATE_ALWAYS,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
(HANDLE)NULL);
|
|
||||||
|
|
||||||
if (hf == INVALID_HANDLE_VALUE)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
|
|
||||||
// Compute the size of the entire file.
|
|
||||||
hdr.bfSize = (DWORD)(sizeof(BITMAPFILEHEADER) +
|
|
||||||
pbih->biSize + pbih->biClrUsed
|
|
||||||
* sizeof(RGBQUAD) + pbih->biSizeImage);
|
|
||||||
hdr.bfReserved1 = 0;
|
|
||||||
hdr.bfReserved2 = 0;
|
|
||||||
|
|
||||||
// Compute the offset to the array of color indices.
|
|
||||||
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
|
|
||||||
pbih->biSize + pbih->biClrUsed
|
|
||||||
* sizeof(RGBQUAD);
|
|
||||||
|
|
||||||
// Copy the BITMAPFILEHEADER into the .BMP file.
|
|
||||||
if (!WriteFile(hf, (LPVOID)&hdr, sizeof(BITMAPFILEHEADER),
|
|
||||||
(LPDWORD)&dwTmp, NULL))
|
|
||||||
{
|
|
||||||
result = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
|
|
||||||
if (!WriteFile(hf, (LPVOID)pbih, sizeof(BITMAPINFOHEADER)
|
|
||||||
+ pbih->biClrUsed * sizeof(RGBQUAD),
|
|
||||||
(LPDWORD)&dwTmp, (NULL)))
|
|
||||||
result = FALSE;
|
|
||||||
|
|
||||||
// Copy the array of color indices into the .BMP file.
|
|
||||||
dwTotal = cb = pbih->biSizeImage;
|
|
||||||
hp = lpBits;
|
|
||||||
if (!WriteFile(hf, (LPSTR)hp, (int)cb, (LPDWORD)&dwTmp, NULL))
|
|
||||||
result = FALSE;
|
|
||||||
|
|
||||||
// Close the .BMP file.
|
|
||||||
if (!CloseHandle(hf))
|
|
||||||
result = FALSE;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <png.h>
|
|
||||||
|
|
||||||
BOOL screenshot(struct IDirectDrawSurfaceImpl *src)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
FILE *fh;
|
|
||||||
char title[128];
|
|
||||||
char filename[128];
|
|
||||||
|
|
||||||
png_structp png_ptr;
|
|
||||||
png_infop info_ptr;
|
|
||||||
png_bytep *row_pointers;
|
|
||||||
png_color palette[256];
|
|
||||||
|
|
||||||
char str_time[64];
|
|
||||||
time_t t = time(NULL);
|
|
||||||
|
|
||||||
strncpy(title, ddraw->title, sizeof(ddraw->title));
|
|
||||||
|
|
||||||
for(i=0;i<strlen(title);i++) {
|
|
||||||
if(title[i] == ' ')
|
|
||||||
{
|
|
||||||
title[i] = '_';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title[i] = tolower(title[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
strftime(str_time, 64, "%Y-%m-%d-%H_%M_%S", localtime(&t));
|
strftime(str_time, 64, "%Y-%m-%d-%H_%M_%S", localtime(&t));
|
||||||
_snprintf(filename, 128, "%s-%s.png", title, str_time);
|
_snprintf(filename, 128, "%s-%s.png", title, str_time);
|
||||||
|
|
||||||
if(!src || !src->palette)
|
unsigned char* png;
|
||||||
|
size_t pngsize;
|
||||||
|
LodePNGState state;
|
||||||
|
|
||||||
|
lodepng_state_init(&state);
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
return FALSE;
|
RGBQUAD *c = &src->palette->data_rgb[i];
|
||||||
|
lodepng_palette_add(&state.info_png.color, c->rgbRed, c->rgbGreen, c->rgbBlue, 255);
|
||||||
|
lodepng_palette_add(&state.info_raw, c->rgbRed, c->rgbGreen, c->rgbBlue, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !(fh = fopen(filename, "wb")) )
|
state.info_png.color.colortype = LCT_PALETTE;
|
||||||
{
|
state.info_png.color.bitdepth = 8;
|
||||||
return FALSE;
|
state.info_raw.colortype = LCT_PALETTE;
|
||||||
}
|
state.info_raw.bitdepth = 8;
|
||||||
|
state.encoder.auto_convert = 0;
|
||||||
|
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
unsigned int error = lodepng_encode(&png, &pngsize, src->surface, src->width, src->height, &state);
|
||||||
if(!png_ptr)
|
if (!error) lodepng_save_file(png, pngsize, filename);
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
lodepng_state_cleanup(&state);
|
||||||
|
free(png);
|
||||||
|
|
||||||
for(i=0;i<256;i++) {
|
return !error;
|
||||||
palette[i].red = src->palette->data_bgr[i];
|
|
||||||
palette[i].green = src->palette->data_bgr[i] >> 8;
|
|
||||||
palette[i].blue = src->palette->data_bgr[i] >> 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
setjmp(png_jmpbuf(png_ptr));
|
|
||||||
|
|
||||||
png_init_io(png_ptr, fh);
|
|
||||||
|
|
||||||
png_set_IHDR(png_ptr, info_ptr, src->width, src->height, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
|
||||||
png_set_PLTE(png_ptr, info_ptr, (png_colorp)&palette, 256);
|
|
||||||
|
|
||||||
row_pointers = (png_bytep *)png_malloc(png_ptr, sizeof(png_bytep) * src->height);
|
|
||||||
|
|
||||||
for(i=0;i<src->height;i++) {
|
|
||||||
row_pointers[i] = src->surface + (src->width * i);
|
|
||||||
}
|
|
||||||
|
|
||||||
png_set_rows(png_ptr, info_ptr, row_pointers);
|
|
||||||
|
|
||||||
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
|
|
||||||
|
|
||||||
fclose(fh);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user