• R/O
  • SSH

thirdparty-pngdib: Commit

A repository containing pngdib, which is planned to be incorporated into WinDirStat.

Its original home is over at http://entropymine.com/jason/pngdib/


Commit MetaInfo

Révision01ac235d4a64fad75cb519eb272f05e7fd079ba7 (tree)
l'heure2014-01-18 13:24:47
AuteurOliver Schneider <oliver@assa...>
CommiterOliver Schneider

Message de Log

Version 3.0.2 from ZIP at http://entropymine.com/jason/pngdib/

Change Summary

Modification

diff -r d318a549c7e1 -r 01ac235d4a64 bmp2png/bmp2png.c
--- a/bmp2png/bmp2png.c Sat Jan 18 04:23:01 2014 +0000
+++ b/bmp2png/bmp2png.c Sat Jan 18 04:24:47 2014 +0000
@@ -3,115 +3,62 @@
33 // converts a BMP image file to a PNG image file
44
55 #include <windows.h>
6+#include <tchar.h>
67 #include <stdio.h>
8+#include <stdlib.h>
9+#include <malloc.h>
710 #include <pngdib.h>
811
9-//#define DIB_ALPHA32
12+#define B2P_ERROR 0
13+#define B2P_OK 1
1014
1115 // Read a file into a memory block.
12-int read_bmp_to_mem(char *bmpfn,unsigned char **bmppp, DWORD *fsizep)
16+static int read_file_to_mem(const TCHAR *fn,unsigned char **pmem, DWORD *pfsize)
1317 {
14- HANDLE hfile;
18+ HANDLE hfile=INVALID_HANDLE_VALUE;
1519 DWORD fsize;
16- unsigned char *fbuf;
20+ void *fbuf;
1721 DWORD bytesread;
22+ int retval=B2P_ERROR;
1823
19- hfile=CreateFile(bmpfn,GENERIC_READ,FILE_SHARE_READ,NULL,
24+ hfile=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ,NULL,
2025 OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
21- if(hfile==INVALID_HANDLE_VALUE) return 1;
26+ if(hfile==INVALID_HANDLE_VALUE) goto done;
2227
2328 fsize=GetFileSize(hfile,NULL);
24- if(fsize>0) {
25- fbuf=(unsigned char*)GlobalAlloc(GPTR,fsize);
26- if(fbuf) {
27- if(ReadFile(hfile,(void*)fbuf,fsize,&bytesread,NULL)) {
28- if(bytesread==fsize) {
29- (*bmppp) = fbuf;
30- (*fsizep) = fsize;
31- CloseHandle(hfile);
32- return 0; // success
33- }
34- }
35- GlobalFree((void*)fbuf);
36- }
37- }
38- CloseHandle(hfile);
39- return 1; // error
29+ if(fsize==INVALID_FILE_SIZE || fsize<=0) goto done;
30+
31+ fbuf=malloc(fsize);
32+ if(!fbuf) goto done;
33+
34+ if(!ReadFile(hfile,fbuf,fsize,&bytesread,NULL)) goto done;
35+ if(bytesread!=fsize) goto done;
36+
37+ *pmem = fbuf;
38+ fbuf=NULL; // Don't free the memory; it's now owned by the caller.
39+ *pfsize = fsize;
40+ retval= B2P_OK;
41+
42+done:
43+ if(hfile!=INVALID_HANDLE_VALUE) CloseHandle(hfile);
44+ if(fbuf) free(fbuf);
45+ return retval;
4046 }
4147
42-static int bmp2png_v2compatible(char *bmpfn, char *pngfn)
48+static int bmp2png_v3(const TCHAR *bmpfn, const TCHAR *pngfn)
4349 {
44- PNGD_D2PINFO d2p;
45- unsigned char *bmpp;
46- DWORD bmpsize;
47- LPBITMAPFILEHEADER lpbmfh;
48- char errmsg[100];
49- int ret;
50-
51- if(read_bmp_to_mem(bmpfn,&bmpp, &bmpsize)) {
52- fprintf(stderr,"can't read BMP from file\n");
53- return 1;
54- }
55-
56- ZeroMemory((void*)&d2p,sizeof(PNGD_D2PINFO));
57-
58- d2p.structsize=sizeof(PNGD_D2PINFO);
59-
60- d2p.flags=0;
61-#ifdef DIB_ALPHA32
62- d2p.flags |= PNGD_DIB_ALPHA32;
63-#endif
64-
65- d2p.pngfn=pngfn;
66-
67- // The first 14 bytes of a BMP file is a file header, the
68- // rest is a DIB.
69- d2p.lpdib = (LPBITMAPINFOHEADER)&bmpp[14];
70-
71- // This can be left at 0 if you know your DIB is valid.
72- d2p.dibsize = bmpsize-14;
73-
74- lpbmfh= (LPBITMAPFILEHEADER)bmpp;
75- if(lpbmfh->bfOffBits >= bmpsize) {
76- fprintf(stderr,"Corrupt BMP\n");
77- return 1;
78- }
79-
80- // It's usually okay to leave lpbits set to NULL.
81- d2p.lpbits = &bmpp[lpbmfh->bfOffBits];
82-
83- // This can be left at 0 if you know your DIB is valid.
84- d2p.bitssize = bmpsize-lpbmfh->bfOffBits;
85-
86- d2p.software = "PNGDIB test app";
87- d2p.errmsg = errmsg; strcpy(errmsg,"");
88-
89- ret=write_dib_to_png(&d2p);
90- // returns 0 on success
91- if(ret) {
92- fprintf(stderr,"Error: %s (%d)\n",d2p.errmsg,ret);
93- return 1;
94- }
95-
96- //
97- GlobalFree(bmpp);
98- return 0;
99-}
100-
101-
102-static int bmp2png_v3(char *bmpfn, char *pngfn)
103-{
104- unsigned char *bmpp;
50+ unsigned char *bmpp=NULL;
10551 DWORD bmpsize;
10652 LPBITMAPINFOHEADER pdib;
10753 LPBITMAPFILEHEADER pbmfh;
10854 void *pbits;
109- PNGDIB *pngdib;
55+ PNGDIB *pngdib=NULL;
11056 int ret;
57+ int retval=B2P_ERROR;
11158
112- if(read_bmp_to_mem(bmpfn,&bmpp, &bmpsize)) {
113- fprintf(stderr,"can't read BMP from file\n");
114- return 1;
59+ if(read_file_to_mem(bmpfn,&bmpp, &bmpsize) != B2P_OK) {
60+ _ftprintf(stderr,_T("Can't read BMP from file\n"));
61+ goto done;
11562 }
11663
11764 pbmfh = (LPBITMAPFILEHEADER)bmpp;
@@ -119,31 +66,34 @@
11966 pdib = (LPBITMAPINFOHEADER)&bmpp[14];
12067
12168 pngdib=pngdib_d2p_init();
69+ if(!pngdib) goto done;
12270 pngdib_d2p_set_dib(pngdib,pdib,bmpsize-14,pbits,0);
12371 pngdib_d2p_set_png_filename(pngdib,pngfn);
12472 pngdib_d2p_set_gamma_label(pngdib, 1, PNGDIB_DEFAULT_FILE_GAMMA);
12573 ret=pngdib_d2p_run(pngdib);
126- pngdib_done(pngdib);
127- if(ret) {
128- fprintf(stderr,"Error: %s (%d)\n",pngdib_get_error_msg(pngdib),ret);
129- return 1;
74+ if(ret!=PNGD_E_SUCCESS) {
75+ _ftprintf(stderr,_T("Error: %s (%d)\n"),pngdib_get_error_msg(pngdib),ret);
76+ goto done;
13077 }
131- return 0;
78+
79+done:
80+ if(bmpp) free(bmpp);
81+ if(pngdib) pngdib_done(pngdib);
82+ return retval;
13283 }
13384
134-int main(int argc,char **argv)
85+int _tmain(int argc, TCHAR *argv[])
13586 {
136- char *bmpfn,*pngfn;
87+ TCHAR *bmpfn,*pngfn;
88+ int ret;
13789
13890 if(argc!=3) {
139- fprintf(stderr,"Usage: %s <file.bmp> <file.png>\n",argv[0]);
91+ _ftprintf(stderr,_T("Usage: %s <file.bmp> <file.png>\n"),argv[0]);
14092 return 1;
14193 }
14294 bmpfn=argv[1];
14395 pngfn=argv[2];
14496
145- //return bmp2png_v2compatible(bmpfn,pngfn);
146- return bmp2png_v3(bmpfn,pngfn);
147-
97+ ret=bmp2png_v3(bmpfn,pngfn);
98+ return (ret==B2P_OK)?0:1;
14899 }
149-
diff -r d318a549c7e1 -r 01ac235d4a64 bmp2png/bmp2png.dsp
--- a/bmp2png/bmp2png.dsp Sat Jan 18 04:23:01 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
1-# Microsoft Developer Studio Project File - Name="bmp2png" - Package Owner=<4>
2-# Microsoft Developer Studio Generated Build File, Format Version 6.00
3-# ** DO NOT EDIT **
4-
5-# TARGTYPE "Win32 (x86) Console Application" 0x0103
6-
7-CFG=bmp2png - Win32 Debug
8-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9-!MESSAGE use the Export Makefile command and run
10-!MESSAGE
11-!MESSAGE NMAKE /f "bmp2png.mak".
12-!MESSAGE
13-!MESSAGE You can specify a configuration when running NMAKE
14-!MESSAGE by defining the macro CFG on the command line. For example:
15-!MESSAGE
16-!MESSAGE NMAKE /f "bmp2png.mak" CFG="bmp2png - Win32 Debug"
17-!MESSAGE
18-!MESSAGE Possible choices for configuration are:
19-!MESSAGE
20-!MESSAGE "bmp2png - Win32 Release" (based on "Win32 (x86) Console Application")
21-!MESSAGE "bmp2png - Win32 Debug" (based on "Win32 (x86) Console Application")
22-!MESSAGE
23-
24-# Begin Project
25-# PROP AllowPerConfigDependencies 0
26-# PROP Scc_ProjName ""
27-# PROP Scc_LocalPath ""
28-CPP=cl.exe
29-RSC=rc.exe
30-
31-!IF "$(CFG)" == "bmp2png - Win32 Release"
32-
33-# PROP BASE Use_MFC 0
34-# PROP BASE Use_Debug_Libraries 0
35-# PROP BASE Output_Dir "Release"
36-# PROP BASE Intermediate_Dir "Release"
37-# PROP BASE Target_Dir ""
38-# PROP Use_MFC 0
39-# PROP Use_Debug_Libraries 0
40-# PROP Output_Dir "Release"
41-# PROP Intermediate_Dir "Release"
42-# PROP Ignore_Export_Lib 0
43-# PROP Target_Dir ""
44-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
45-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
46-# ADD BASE RSC /l 0x409 /d "NDEBUG"
47-# ADD RSC /l 0x409 /d "NDEBUG"
48-BSC32=bscmake.exe
49-# ADD BASE BSC32 /nologo
50-# ADD BSC32 /nologo
51-LINK32=link.exe
52-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53-# ADD LINK32 ..\..\libpng-1.2.5\Release\libpng.lib ..\..\zlib-1.1.4\Release\zlib.lib ..\Release\pngdib.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:console /machine:I386
54-
55-!ELSEIF "$(CFG)" == "bmp2png - Win32 Debug"
56-
57-# PROP BASE Use_MFC 0
58-# PROP BASE Use_Debug_Libraries 1
59-# PROP BASE Output_Dir "Debug"
60-# PROP BASE Intermediate_Dir "Debug"
61-# PROP BASE Target_Dir ""
62-# PROP Use_MFC 0
63-# PROP Use_Debug_Libraries 1
64-# PROP Output_Dir "Debug"
65-# PROP Intermediate_Dir "Debug"
66-# PROP Ignore_Export_Lib 0
67-# PROP Target_Dir ""
68-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
69-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
70-# ADD BASE RSC /l 0x409 /d "_DEBUG"
71-# ADD RSC /l 0x409 /d "_DEBUG"
72-BSC32=bscmake.exe
73-# ADD BASE BSC32 /nologo
74-# ADD BSC32 /nologo
75-LINK32=link.exe
76-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
77-# ADD LINK32 ..\..\libpng-1.2.5\Debug\libpng.lib ..\..\zlib-1.1.4\Debug\zlib.lib ..\Debug\pngdib.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
78-
79-!ENDIF
80-
81-# Begin Target
82-
83-# Name "bmp2png - Win32 Release"
84-# Name "bmp2png - Win32 Debug"
85-# Begin Source File
86-
87-SOURCE=.\bmp2png.c
88-# End Source File
89-# End Target
90-# End Project
diff -r d318a549c7e1 -r 01ac235d4a64 bmp2png/bmp2png.vcproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bmp2png/bmp2png.vcproj Sat Jan 18 04:24:47 2014 +0000
@@ -0,0 +1,387 @@
1+<?xml version="1.0" encoding="Windows-1252"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="9.00"
5+ Name="bmp2png"
6+ ProjectGUID="{AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}"
7+ RootNamespace="bmp2png"
8+ TargetFrameworkVersion="0"
9+ >
10+ <Platforms>
11+ <Platform
12+ Name="Win32"
13+ />
14+ </Platforms>
15+ <ToolFiles>
16+ </ToolFiles>
17+ <Configurations>
18+ <Configuration
19+ Name="Release|Win32"
20+ OutputDirectory="$(ConfigurationName)"
21+ IntermediateDirectory="$(ConfigurationName)"
22+ ConfigurationType="1"
23+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
24+ UseOfMFC="0"
25+ ATLMinimizesCRunTimeLibraryUsage="false"
26+ CharacterSet="2"
27+ >
28+ <Tool
29+ Name="VCPreBuildEventTool"
30+ />
31+ <Tool
32+ Name="VCCustomBuildTool"
33+ />
34+ <Tool
35+ Name="VCXMLDataGeneratorTool"
36+ />
37+ <Tool
38+ Name="VCWebServiceProxyGeneratorTool"
39+ />
40+ <Tool
41+ Name="VCMIDLTool"
42+ TypeLibraryName=".\Release/bmp2png.tlb"
43+ HeaderFileName=""
44+ />
45+ <Tool
46+ Name="VCCLCompilerTool"
47+ Optimization="2"
48+ AdditionalIncludeDirectories="..\"
49+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
50+ StringPooling="true"
51+ RuntimeLibrary="0"
52+ EnableFunctionLevelLinking="true"
53+ WarningLevel="3"
54+ SuppressStartupBanner="true"
55+ />
56+ <Tool
57+ Name="VCManagedResourceCompilerTool"
58+ />
59+ <Tool
60+ Name="VCResourceCompilerTool"
61+ PreprocessorDefinitions="NDEBUG"
62+ Culture="1033"
63+ />
64+ <Tool
65+ Name="VCPreLinkEventTool"
66+ />
67+ <Tool
68+ Name="VCLinkerTool"
69+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
70+ OutputFile="$(OutDir)/bmp2png.exe"
71+ LinkIncremental="1"
72+ SuppressStartupBanner="true"
73+ SubSystem="1"
74+ />
75+ <Tool
76+ Name="VCALinkTool"
77+ />
78+ <Tool
79+ Name="VCManifestTool"
80+ />
81+ <Tool
82+ Name="VCXDCMakeTool"
83+ />
84+ <Tool
85+ Name="VCBscMakeTool"
86+ SuppressStartupBanner="true"
87+ />
88+ <Tool
89+ Name="VCFxCopTool"
90+ />
91+ <Tool
92+ Name="VCAppVerifierTool"
93+ />
94+ <Tool
95+ Name="VCPostBuildEventTool"
96+ />
97+ </Configuration>
98+ <Configuration
99+ Name="Debug|Win32"
100+ OutputDirectory="$(ConfigurationName)"
101+ IntermediateDirectory="$(ConfigurationName)"
102+ ConfigurationType="1"
103+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
104+ UseOfMFC="0"
105+ ATLMinimizesCRunTimeLibraryUsage="false"
106+ CharacterSet="2"
107+ >
108+ <Tool
109+ Name="VCPreBuildEventTool"
110+ />
111+ <Tool
112+ Name="VCCustomBuildTool"
113+ />
114+ <Tool
115+ Name="VCXMLDataGeneratorTool"
116+ />
117+ <Tool
118+ Name="VCWebServiceProxyGeneratorTool"
119+ />
120+ <Tool
121+ Name="VCMIDLTool"
122+ TypeLibraryName=".\Debug/bmp2png.tlb"
123+ HeaderFileName=""
124+ />
125+ <Tool
126+ Name="VCCLCompilerTool"
127+ Optimization="0"
128+ AdditionalIncludeDirectories="..\"
129+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
130+ MinimalRebuild="true"
131+ RuntimeLibrary="1"
132+ WarningLevel="3"
133+ SuppressStartupBanner="true"
134+ DebugInformationFormat="4"
135+ />
136+ <Tool
137+ Name="VCManagedResourceCompilerTool"
138+ />
139+ <Tool
140+ Name="VCResourceCompilerTool"
141+ PreprocessorDefinitions="_DEBUG"
142+ Culture="1033"
143+ />
144+ <Tool
145+ Name="VCPreLinkEventTool"
146+ />
147+ <Tool
148+ Name="VCLinkerTool"
149+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
150+ OutputFile="$(OutDir)/bmp2png.exe"
151+ LinkIncremental="2"
152+ SuppressStartupBanner="true"
153+ GenerateDebugInformation="true"
154+ SubSystem="1"
155+ />
156+ <Tool
157+ Name="VCALinkTool"
158+ />
159+ <Tool
160+ Name="VCManifestTool"
161+ />
162+ <Tool
163+ Name="VCXDCMakeTool"
164+ />
165+ <Tool
166+ Name="VCBscMakeTool"
167+ SuppressStartupBanner="true"
168+ />
169+ <Tool
170+ Name="VCFxCopTool"
171+ />
172+ <Tool
173+ Name="VCAppVerifierTool"
174+ />
175+ <Tool
176+ Name="VCPostBuildEventTool"
177+ />
178+ </Configuration>
179+ <Configuration
180+ Name="DebugU|Win32"
181+ OutputDirectory="$(ConfigurationName)"
182+ IntermediateDirectory="$(ConfigurationName)"
183+ ConfigurationType="1"
184+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
185+ UseOfMFC="0"
186+ ATLMinimizesCRunTimeLibraryUsage="false"
187+ CharacterSet="1"
188+ >
189+ <Tool
190+ Name="VCPreBuildEventTool"
191+ />
192+ <Tool
193+ Name="VCCustomBuildTool"
194+ />
195+ <Tool
196+ Name="VCXMLDataGeneratorTool"
197+ />
198+ <Tool
199+ Name="VCWebServiceProxyGeneratorTool"
200+ />
201+ <Tool
202+ Name="VCMIDLTool"
203+ TypeLibraryName=".\Debug/bmp2png.tlb"
204+ HeaderFileName=""
205+ />
206+ <Tool
207+ Name="VCCLCompilerTool"
208+ Optimization="0"
209+ AdditionalIncludeDirectories="..\"
210+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
211+ MinimalRebuild="true"
212+ RuntimeLibrary="1"
213+ WarningLevel="3"
214+ SuppressStartupBanner="true"
215+ DebugInformationFormat="4"
216+ />
217+ <Tool
218+ Name="VCManagedResourceCompilerTool"
219+ />
220+ <Tool
221+ Name="VCResourceCompilerTool"
222+ PreprocessorDefinitions="_DEBUG"
223+ Culture="1033"
224+ />
225+ <Tool
226+ Name="VCPreLinkEventTool"
227+ />
228+ <Tool
229+ Name="VCLinkerTool"
230+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
231+ OutputFile="$(OutDir)/bmp2png.exe"
232+ LinkIncremental="2"
233+ SuppressStartupBanner="true"
234+ GenerateDebugInformation="true"
235+ SubSystem="1"
236+ />
237+ <Tool
238+ Name="VCALinkTool"
239+ />
240+ <Tool
241+ Name="VCManifestTool"
242+ />
243+ <Tool
244+ Name="VCXDCMakeTool"
245+ />
246+ <Tool
247+ Name="VCBscMakeTool"
248+ SuppressStartupBanner="true"
249+ />
250+ <Tool
251+ Name="VCFxCopTool"
252+ />
253+ <Tool
254+ Name="VCAppVerifierTool"
255+ />
256+ <Tool
257+ Name="VCPostBuildEventTool"
258+ />
259+ </Configuration>
260+ <Configuration
261+ Name="ReleaseU|Win32"
262+ OutputDirectory="$(ConfigurationName)"
263+ IntermediateDirectory="$(ConfigurationName)"
264+ ConfigurationType="1"
265+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
266+ UseOfMFC="0"
267+ ATLMinimizesCRunTimeLibraryUsage="false"
268+ CharacterSet="1"
269+ >
270+ <Tool
271+ Name="VCPreBuildEventTool"
272+ />
273+ <Tool
274+ Name="VCCustomBuildTool"
275+ />
276+ <Tool
277+ Name="VCXMLDataGeneratorTool"
278+ />
279+ <Tool
280+ Name="VCWebServiceProxyGeneratorTool"
281+ />
282+ <Tool
283+ Name="VCMIDLTool"
284+ TypeLibraryName=".\Release/bmp2png.tlb"
285+ HeaderFileName=""
286+ />
287+ <Tool
288+ Name="VCCLCompilerTool"
289+ Optimization="2"
290+ AdditionalIncludeDirectories="..\"
291+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
292+ StringPooling="true"
293+ RuntimeLibrary="0"
294+ EnableFunctionLevelLinking="true"
295+ WarningLevel="3"
296+ SuppressStartupBanner="true"
297+ />
298+ <Tool
299+ Name="VCManagedResourceCompilerTool"
300+ />
301+ <Tool
302+ Name="VCResourceCompilerTool"
303+ PreprocessorDefinitions="NDEBUG"
304+ Culture="1033"
305+ />
306+ <Tool
307+ Name="VCPreLinkEventTool"
308+ />
309+ <Tool
310+ Name="VCLinkerTool"
311+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
312+ OutputFile="$(OutDir)/bmp2png.exe"
313+ LinkIncremental="1"
314+ SuppressStartupBanner="true"
315+ SubSystem="1"
316+ />
317+ <Tool
318+ Name="VCALinkTool"
319+ />
320+ <Tool
321+ Name="VCManifestTool"
322+ />
323+ <Tool
324+ Name="VCXDCMakeTool"
325+ />
326+ <Tool
327+ Name="VCBscMakeTool"
328+ SuppressStartupBanner="true"
329+ />
330+ <Tool
331+ Name="VCFxCopTool"
332+ />
333+ <Tool
334+ Name="VCAppVerifierTool"
335+ />
336+ <Tool
337+ Name="VCPostBuildEventTool"
338+ />
339+ </Configuration>
340+ </Configurations>
341+ <References>
342+ </References>
343+ <Files>
344+ <File
345+ RelativePath="bmp2png.c"
346+ >
347+ <FileConfiguration
348+ Name="Release|Win32"
349+ >
350+ <Tool
351+ Name="VCCLCompilerTool"
352+ AdditionalIncludeDirectories=""
353+ PreprocessorDefinitions=""
354+ />
355+ </FileConfiguration>
356+ <FileConfiguration
357+ Name="Debug|Win32"
358+ >
359+ <Tool
360+ Name="VCCLCompilerTool"
361+ AdditionalIncludeDirectories=""
362+ PreprocessorDefinitions=""
363+ />
364+ </FileConfiguration>
365+ <FileConfiguration
366+ Name="DebugU|Win32"
367+ >
368+ <Tool
369+ Name="VCCLCompilerTool"
370+ AdditionalIncludeDirectories=""
371+ PreprocessorDefinitions=""
372+ />
373+ </FileConfiguration>
374+ <FileConfiguration
375+ Name="ReleaseU|Win32"
376+ >
377+ <Tool
378+ Name="VCCLCompilerTool"
379+ AdditionalIncludeDirectories=""
380+ PreprocessorDefinitions=""
381+ />
382+ </FileConfiguration>
383+ </File>
384+ </Files>
385+ <Globals>
386+ </Globals>
387+</VisualStudioProject>
diff -r d318a549c7e1 -r 01ac235d4a64 png2bmp/png2bmp.c
--- a/png2bmp/png2bmp.c Sat Jan 18 04:23:01 2014 +0000
+++ b/png2bmp/png2bmp.c Sat Jan 18 04:24:47 2014 +0000
@@ -3,53 +3,55 @@
33 // convert a PNG image file to a BMP image file
44
55 #include <windows.h>
6+#include <tchar.h>
67 #include <stdio.h>
8+#include <stdlib.h>
9+#include <malloc.h>
710 #include <pngdib.h>
811
12+#define P2B_ERROR 1
13+#define P2B_OK 0
914
1015 // Read a file into a memory block.
11-static int read_file_to_mem(char *fn,unsigned char **ppfiledata, int *pfilesize)
16+static int read_file_to_mem(const TCHAR *fn,unsigned char **pmem, DWORD *pfsize)
1217 {
13- HANDLE hfile;
18+ HANDLE hfile=INVALID_HANDLE_VALUE;
1419 DWORD fsize;
15- unsigned char *fbuf;
20+ void *fbuf;
1621 DWORD bytesread;
22+ int retval=P2B_ERROR;
1723
1824 hfile=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ,NULL,
1925 OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
20- if(hfile==INVALID_HANDLE_VALUE) return 1;
26+ if(hfile==INVALID_HANDLE_VALUE) goto done;
2127
2228 fsize=GetFileSize(hfile,NULL);
23- if(fsize>0) {
24- //fbuf=(unsigned char*)GlobalAlloc(GPTR,fsize);
25- fbuf=(unsigned char*)calloc(fsize,1);
26- if(fbuf) {
27- if(ReadFile(hfile,(void*)fbuf,fsize,&bytesread,NULL)) {
28- if(bytesread==fsize) {
29- (*ppfiledata) = fbuf;
30- (*pfilesize) = (int)fsize;
31- CloseHandle(hfile);
32- return 0; // success
33- }
34- }
35- free((void*)fbuf);
36- }
37- }
38- CloseHandle(hfile);
39- return 1; // error
29+ if(fsize==INVALID_FILE_SIZE || fsize<=0) goto done;
30+
31+ fbuf=malloc(fsize);
32+ if(!fbuf) goto done;
33+
34+ if(!ReadFile(hfile,fbuf,fsize,&bytesread,NULL)) goto done;
35+ if(bytesread!=fsize) goto done;
36+
37+ *pmem = fbuf;
38+ fbuf=NULL; // Don't free the memory; it's now owned by the caller.
39+ *pfsize = fsize;
40+ retval= P2B_OK;
41+
42+done:
43+ if(hfile!=INVALID_HANDLE_VALUE) CloseHandle(hfile);
44+ if(fbuf) free(fbuf);
45+ return retval;
4046 }
4147
42-
43-
44-//DIB_ALPHA32 is an experiment -- just leave it commented out.
45-//#define DIB_ALPHA32
46-
47-static int write_dib_to_bmp(char *bmpfn, LPBITMAPINFOHEADER pdib,
48+static int write_dib_to_bmp(const TCHAR *bmpfn, LPBITMAPINFOHEADER pdib,
4849 int dibsize, int bitsoffset)
4950 {
50- HANDLE hfile;
51+ HANDLE hfile=INVALID_HANDLE_VALUE;
5152 BITMAPFILEHEADER h;
52- DWORD written, err;
53+ DWORD written;
54+ int retval=P2B_ERROR;
5355
5456 ZeroMemory((void*)&h,sizeof(h));
5557 h.bfType= MAKEWORD('B','M');
@@ -58,83 +60,43 @@
5860
5961 hfile=CreateFile(bmpfn,GENERIC_WRITE,FILE_SHARE_READ,NULL,
6062 CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
61- if(hfile==INVALID_HANDLE_VALUE) return 1;
63+ if(hfile==INVALID_HANDLE_VALUE) goto done;
6264
6365 if(!WriteFile(hfile,(void*)&h,sizeof(BITMAPFILEHEADER),&written,NULL)) {
64- err=GetLastError();
65- CloseHandle(hfile);
66- return 1;
66+ goto done;
6767 }
6868 if(!WriteFile(hfile,(void*)pdib,dibsize,&written,NULL)) {
69- err=GetLastError();
70- CloseHandle(hfile);
71- return 1;
69+ goto done;
7270 }
73- CloseHandle(hfile);
74- return 0;
71+ retval=P2B_OK;
72+
73+done:
74+ if(hfile!=INVALID_HANDLE_VALUE) CloseHandle(hfile);
75+ return retval;
7576 }
7677
77-
78-static int png2bmp_v2compatible(char *pngfn, char *bmpfn)
78+static int png2bmp_v3(const TCHAR *pngfn, const TCHAR *bmpfn, int frommem)
7979 {
80- PNGD_P2DINFO p2d;
80+ PNGDIB *pngdib=NULL;
8181 int ret;
82- char errmsg[100];
83-
84- ZeroMemory((void*)&p2d,sizeof(PNGD_P2DINFO));
85-
86- p2d.structsize=sizeof(PNGD_P2DINFO);
87- p2d.flags=0;
88-#ifdef DIB_ALPHA32
89- p2d.flags |= PNGD_DIB_ALPHA32;
90-#else
91- p2d.flags |= PNGD_GAMMA_CORRECTION;
92-#endif
93- p2d.pngfn=pngfn; // name of the file to read
94- p2d.errmsg=errmsg; strcpy(errmsg,"");
95-
96- ret=read_png_to_dib(&p2d);
97- // returns 0 on success
98- if(ret) {
99- // see pngdib.h for a list of error codes
100- fprintf(stderr,"Error: %s (%d)\n",errmsg,ret);
101- return 1;
102- }
103-
104- if(write_dib_to_bmp(bmpfn, p2d.lpdib, p2d.dibsize, p2d.bits_offs)) {
105- fprintf(stderr,"Can't write BMP file\n");
106- }
107-
108- // The DIB will have been allocated with GlobalAlloc(GMEM_FIXED...).
109- // You should free it with GlobalFree when you're done with it.
110- GlobalFree((void*)p2d.lpdib);
111-
112- return 0;
113-}
114-
115-static int png2bmp_v3(char *pngfn, char *bmpfn, int frommem)
116-{
117- PNGDIB *pngdib;
118- int errcode, retval;
82+ int retval=P2B_ERROR;
11983 LPBITMAPINFOHEADER pdib;
12084 int dib_size;
12185 void *pdib_bits;
12286 int bits_offs;
123- unsigned char *memblk;
87+ unsigned char *memblk=NULL;
12488 int memblksize;
125-
126- retval=1;
127-
89+ int need_free_dib=0;
12890
12991 if(frommem) {
130- if(read_file_to_mem(pngfn,&memblk, &memblksize)) {
131- fprintf(stderr,"Can't read %s\n",pngfn);
132- return 1;
92+ if(read_file_to_mem(pngfn,&memblk, &memblksize) != P2B_OK) {
93+ _ftprintf(stderr,_T("Can't read %s\n"),pngfn);
94+ goto done;
13395 }
13496 }
13597
13698 pngdib = pngdib_p2d_init();
137- if(!pngdib) return 1;
99+ if(!pngdib) goto done;
138100
139101 if(frommem) {
140102 pngdib_p2d_set_png_memblk(pngdib,memblk,memblksize);
@@ -145,50 +107,53 @@
145107
146108 //pngdib_p2d_set_gamma_correction(pngdib,PNGDIB_DEFAULT_SCREEN_GAMMA);
147109 pngdib_p2d_set_use_file_bg(pngdib,1);
148- errcode=pngdib_p2d_run(pngdib);
110+ ret=pngdib_p2d_run(pngdib);
111+ if(ret!=PNGD_E_SUCCESS) {
112+ _ftprintf(stderr,_T("Failed to load %s: %s (%d)\n"),pngfn,pngdib_get_error_msg(pngdib),ret);
113+ goto done;
114+ }
115+ need_free_dib=1;
149116
150117 if(frommem) {
151118 // after pngdib_p2d_run, we can free the memory-mapped PNG
152119 free(memblk);
153- }
154-
155- if(errcode) {
156- fprintf(stderr,"Failed to load %s: %s (%d)",pngfn,pngdib_get_error_msg(pngdib),errcode);
157- pngdib_done(pngdib);
158- return 0;
120+ memblk=NULL;
159121 }
160122
161123 pngdib_p2d_get_dib(pngdib,&pdib,&dib_size);
162124 pngdib_p2d_get_dibbits(pngdib,&pdib_bits,&bits_offs,NULL);
163125
164- if(write_dib_to_bmp(bmpfn, pdib, dib_size, bits_offs)) {
165- fprintf(stderr,"Can't write BMP file\n");
126+ if(write_dib_to_bmp(bmpfn, pdib, dib_size, bits_offs) != P2B_OK) {
127+ _ftprintf(stderr,_T("Can't write BMP file\n"));
128+ goto done;
166129 }
167- else
168- retval=0;
169130
170- // if pngdib_p2d_run() succeeds, then we own the bitmap,
171- // and must explicitly free it:
172- pngdib_p2d_free_dib(pngdib,NULL);
131+ retval=P2B_OK;
173132
174- pngdib_done(pngdib);
133+done:
134+ if(pngdib) {
135+ // if pngdib_p2d_run() succeeds, then we own the bitmap,
136+ // and must explicitly free it:
137+ if(need_free_dib) pngdib_p2d_free_dib(pngdib,NULL);
138+ pngdib_done(pngdib);
139+ }
140+ if(memblk) free(memblk);
175141 return retval;
176142 }
177143
178-
179-int main(int argc,char **argv)
144+int _tmain(int argc, TCHAR *argv[])
180145 {
181- char *bmpfn,*pngfn;
182-
146+ TCHAR *bmpfn,*pngfn;
147+ int ret;
183148
184149 if(argc!=3) {
185- printf("Usage: %s <file.png> <file.bmp>\n",argv[0]);
150+ _ftprintf(stderr,_T("Usage: %s <file.png> <file.bmp>\n"),argv[0]);
186151 return 1;
187152 }
188153 pngfn=argv[1];
189154 bmpfn=argv[2];
190155
191- //return png2bmp_v2compatible(pngfn,bmpfn);
192- //return png2bmp_v3(pngfn,bmpfn,0);
193- return png2bmp_v3(pngfn,bmpfn,1);
156+ ret=png2bmp_v3(pngfn,bmpfn,0);
157+ //ret=png2bmp_v3(pngfn,bmpfn,1);
158+ return (ret==P2B_OK)?0:1;
194159 }
diff -r d318a549c7e1 -r 01ac235d4a64 png2bmp/png2bmp.dsp
--- a/png2bmp/png2bmp.dsp Sat Jan 18 04:23:01 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
1-# Microsoft Developer Studio Project File - Name="png2bmp" - Package Owner=<4>
2-# Microsoft Developer Studio Generated Build File, Format Version 6.00
3-# ** DO NOT EDIT **
4-
5-# TARGTYPE "Win32 (x86) Console Application" 0x0103
6-
7-CFG=png2bmp - Win32 Debug
8-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9-!MESSAGE use the Export Makefile command and run
10-!MESSAGE
11-!MESSAGE NMAKE /f "png2bmp.mak".
12-!MESSAGE
13-!MESSAGE You can specify a configuration when running NMAKE
14-!MESSAGE by defining the macro CFG on the command line. For example:
15-!MESSAGE
16-!MESSAGE NMAKE /f "png2bmp.mak" CFG="png2bmp - Win32 Debug"
17-!MESSAGE
18-!MESSAGE Possible choices for configuration are:
19-!MESSAGE
20-!MESSAGE "png2bmp - Win32 Release" (based on "Win32 (x86) Console Application")
21-!MESSAGE "png2bmp - Win32 Debug" (based on "Win32 (x86) Console Application")
22-!MESSAGE
23-
24-# Begin Project
25-# PROP AllowPerConfigDependencies 0
26-# PROP Scc_ProjName ""
27-# PROP Scc_LocalPath ""
28-CPP=cl.exe
29-RSC=rc.exe
30-
31-!IF "$(CFG)" == "png2bmp - Win32 Release"
32-
33-# PROP BASE Use_MFC 0
34-# PROP BASE Use_Debug_Libraries 0
35-# PROP BASE Output_Dir "Release"
36-# PROP BASE Intermediate_Dir "Release"
37-# PROP BASE Target_Dir ""
38-# PROP Use_MFC 0
39-# PROP Use_Debug_Libraries 0
40-# PROP Output_Dir "Release"
41-# PROP Intermediate_Dir "Release"
42-# PROP Ignore_Export_Lib 0
43-# PROP Target_Dir ""
44-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
45-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
46-# ADD BASE RSC /l 0x409 /d "NDEBUG"
47-# ADD RSC /l 0x409 /d "NDEBUG"
48-BSC32=bscmake.exe
49-# ADD BASE BSC32 /nologo
50-# ADD BSC32 /nologo
51-LINK32=link.exe
52-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
53-# ADD LINK32 ..\..\libpng-1.2.5\Release\libpng.lib ..\..\zlib-1.1.4\Release\zlib.lib ..\Release\pngdib.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:console /machine:I386
54-
55-!ELSEIF "$(CFG)" == "png2bmp - Win32 Debug"
56-
57-# PROP BASE Use_MFC 0
58-# PROP BASE Use_Debug_Libraries 1
59-# PROP BASE Output_Dir "Debug"
60-# PROP BASE Intermediate_Dir "Debug"
61-# PROP BASE Target_Dir ""
62-# PROP Use_MFC 0
63-# PROP Use_Debug_Libraries 1
64-# PROP Output_Dir "Debug"
65-# PROP Intermediate_Dir "Debug"
66-# PROP Ignore_Export_Lib 0
67-# PROP Target_Dir ""
68-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
69-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
70-# ADD BASE RSC /l 0x409 /d "_DEBUG"
71-# ADD RSC /l 0x409 /d "_DEBUG"
72-BSC32=bscmake.exe
73-# ADD BASE BSC32 /nologo
74-# ADD BSC32 /nologo
75-LINK32=link.exe
76-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
77-# ADD LINK32 ..\..\libpng-1.2.5\Debug\libpng.lib ..\..\zlib-1.1.4\Debug\zlib.lib ..\Debug\pngdib.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
78-
79-!ENDIF
80-
81-# Begin Target
82-
83-# Name "png2bmp - Win32 Release"
84-# Name "png2bmp - Win32 Debug"
85-# Begin Source File
86-
87-SOURCE=.\png2bmp.c
88-# End Source File
89-# End Target
90-# End Project
diff -r d318a549c7e1 -r 01ac235d4a64 png2bmp/png2bmp.vcproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/png2bmp/png2bmp.vcproj Sat Jan 18 04:24:47 2014 +0000
@@ -0,0 +1,385 @@
1+<?xml version="1.0" encoding="Windows-1252"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="9.00"
5+ Name="png2bmp"
6+ ProjectGUID="{51736FCB-5C13-419E-BC85-974FCE62E4E1}"
7+ RootNamespace="png2bmp"
8+ TargetFrameworkVersion="0"
9+ >
10+ <Platforms>
11+ <Platform
12+ Name="Win32"
13+ />
14+ </Platforms>
15+ <ToolFiles>
16+ </ToolFiles>
17+ <Configurations>
18+ <Configuration
19+ Name="Release|Win32"
20+ OutputDirectory="$(ConfigurationName)"
21+ IntermediateDirectory="$(ConfigurationName)"
22+ ConfigurationType="1"
23+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
24+ UseOfMFC="0"
25+ ATLMinimizesCRunTimeLibraryUsage="false"
26+ CharacterSet="2"
27+ >
28+ <Tool
29+ Name="VCPreBuildEventTool"
30+ />
31+ <Tool
32+ Name="VCCustomBuildTool"
33+ />
34+ <Tool
35+ Name="VCXMLDataGeneratorTool"
36+ />
37+ <Tool
38+ Name="VCWebServiceProxyGeneratorTool"
39+ />
40+ <Tool
41+ Name="VCMIDLTool"
42+ TypeLibraryName=".\Release/png2bmp.tlb"
43+ HeaderFileName=""
44+ />
45+ <Tool
46+ Name="VCCLCompilerTool"
47+ Optimization="2"
48+ AdditionalIncludeDirectories="..\"
49+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
50+ RuntimeLibrary="0"
51+ WarningLevel="3"
52+ SuppressStartupBanner="true"
53+ />
54+ <Tool
55+ Name="VCManagedResourceCompilerTool"
56+ />
57+ <Tool
58+ Name="VCResourceCompilerTool"
59+ PreprocessorDefinitions="NDEBUG"
60+ Culture="1033"
61+ />
62+ <Tool
63+ Name="VCPreLinkEventTool"
64+ />
65+ <Tool
66+ Name="VCLinkerTool"
67+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
68+ OutputFile="$(OutDir)/png2bmp.exe"
69+ LinkIncremental="1"
70+ SuppressStartupBanner="true"
71+ SubSystem="1"
72+ />
73+ <Tool
74+ Name="VCALinkTool"
75+ />
76+ <Tool
77+ Name="VCManifestTool"
78+ />
79+ <Tool
80+ Name="VCXDCMakeTool"
81+ />
82+ <Tool
83+ Name="VCBscMakeTool"
84+ SuppressStartupBanner="true"
85+ OutputFile=".\Release/png2bmp.bsc"
86+ />
87+ <Tool
88+ Name="VCFxCopTool"
89+ />
90+ <Tool
91+ Name="VCAppVerifierTool"
92+ />
93+ <Tool
94+ Name="VCPostBuildEventTool"
95+ />
96+ </Configuration>
97+ <Configuration
98+ Name="Debug|Win32"
99+ OutputDirectory="$(ConfigurationName)"
100+ IntermediateDirectory="$(ConfigurationName)"
101+ ConfigurationType="1"
102+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
103+ UseOfMFC="0"
104+ ATLMinimizesCRunTimeLibraryUsage="false"
105+ CharacterSet="2"
106+ >
107+ <Tool
108+ Name="VCPreBuildEventTool"
109+ />
110+ <Tool
111+ Name="VCCustomBuildTool"
112+ />
113+ <Tool
114+ Name="VCXMLDataGeneratorTool"
115+ />
116+ <Tool
117+ Name="VCWebServiceProxyGeneratorTool"
118+ />
119+ <Tool
120+ Name="VCMIDLTool"
121+ TypeLibraryName=".\Debug/png2bmp.tlb"
122+ HeaderFileName=""
123+ />
124+ <Tool
125+ Name="VCCLCompilerTool"
126+ Optimization="0"
127+ AdditionalIncludeDirectories="..\"
128+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
129+ MinimalRebuild="true"
130+ RuntimeLibrary="1"
131+ WarningLevel="3"
132+ SuppressStartupBanner="true"
133+ DebugInformationFormat="4"
134+ />
135+ <Tool
136+ Name="VCManagedResourceCompilerTool"
137+ />
138+ <Tool
139+ Name="VCResourceCompilerTool"
140+ PreprocessorDefinitions="_DEBUG"
141+ Culture="1033"
142+ />
143+ <Tool
144+ Name="VCPreLinkEventTool"
145+ />
146+ <Tool
147+ Name="VCLinkerTool"
148+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
149+ OutputFile="$(OutDir)/png2bmp.exe"
150+ LinkIncremental="2"
151+ SuppressStartupBanner="true"
152+ GenerateDebugInformation="true"
153+ SubSystem="1"
154+ />
155+ <Tool
156+ Name="VCALinkTool"
157+ />
158+ <Tool
159+ Name="VCManifestTool"
160+ />
161+ <Tool
162+ Name="VCXDCMakeTool"
163+ />
164+ <Tool
165+ Name="VCBscMakeTool"
166+ SuppressStartupBanner="true"
167+ />
168+ <Tool
169+ Name="VCFxCopTool"
170+ />
171+ <Tool
172+ Name="VCAppVerifierTool"
173+ />
174+ <Tool
175+ Name="VCPostBuildEventTool"
176+ />
177+ </Configuration>
178+ <Configuration
179+ Name="DebugU|Win32"
180+ OutputDirectory="$(ConfigurationName)"
181+ IntermediateDirectory="$(ConfigurationName)"
182+ ConfigurationType="1"
183+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
184+ UseOfMFC="0"
185+ ATLMinimizesCRunTimeLibraryUsage="false"
186+ CharacterSet="1"
187+ >
188+ <Tool
189+ Name="VCPreBuildEventTool"
190+ />
191+ <Tool
192+ Name="VCCustomBuildTool"
193+ />
194+ <Tool
195+ Name="VCXMLDataGeneratorTool"
196+ />
197+ <Tool
198+ Name="VCWebServiceProxyGeneratorTool"
199+ />
200+ <Tool
201+ Name="VCMIDLTool"
202+ TypeLibraryName=".\Debug/png2bmp.tlb"
203+ HeaderFileName=""
204+ />
205+ <Tool
206+ Name="VCCLCompilerTool"
207+ Optimization="0"
208+ AdditionalIncludeDirectories="..\"
209+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
210+ MinimalRebuild="true"
211+ RuntimeLibrary="1"
212+ WarningLevel="3"
213+ SuppressStartupBanner="true"
214+ DebugInformationFormat="4"
215+ />
216+ <Tool
217+ Name="VCManagedResourceCompilerTool"
218+ />
219+ <Tool
220+ Name="VCResourceCompilerTool"
221+ PreprocessorDefinitions="_DEBUG"
222+ Culture="1033"
223+ />
224+ <Tool
225+ Name="VCPreLinkEventTool"
226+ />
227+ <Tool
228+ Name="VCLinkerTool"
229+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
230+ OutputFile="$(OutDir)/png2bmp.exe"
231+ LinkIncremental="2"
232+ SuppressStartupBanner="true"
233+ GenerateDebugInformation="true"
234+ SubSystem="1"
235+ />
236+ <Tool
237+ Name="VCALinkTool"
238+ />
239+ <Tool
240+ Name="VCManifestTool"
241+ />
242+ <Tool
243+ Name="VCXDCMakeTool"
244+ />
245+ <Tool
246+ Name="VCBscMakeTool"
247+ SuppressStartupBanner="true"
248+ />
249+ <Tool
250+ Name="VCFxCopTool"
251+ />
252+ <Tool
253+ Name="VCAppVerifierTool"
254+ />
255+ <Tool
256+ Name="VCPostBuildEventTool"
257+ />
258+ </Configuration>
259+ <Configuration
260+ Name="ReleaseU|Win32"
261+ OutputDirectory="$(ConfigurationName)"
262+ IntermediateDirectory="$(ConfigurationName)"
263+ ConfigurationType="1"
264+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
265+ UseOfMFC="0"
266+ ATLMinimizesCRunTimeLibraryUsage="false"
267+ CharacterSet="1"
268+ >
269+ <Tool
270+ Name="VCPreBuildEventTool"
271+ />
272+ <Tool
273+ Name="VCCustomBuildTool"
274+ />
275+ <Tool
276+ Name="VCXMLDataGeneratorTool"
277+ />
278+ <Tool
279+ Name="VCWebServiceProxyGeneratorTool"
280+ />
281+ <Tool
282+ Name="VCMIDLTool"
283+ TypeLibraryName=".\Release/png2bmp.tlb"
284+ HeaderFileName=""
285+ />
286+ <Tool
287+ Name="VCCLCompilerTool"
288+ Optimization="2"
289+ AdditionalIncludeDirectories="..\"
290+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
291+ RuntimeLibrary="0"
292+ WarningLevel="3"
293+ SuppressStartupBanner="true"
294+ />
295+ <Tool
296+ Name="VCManagedResourceCompilerTool"
297+ />
298+ <Tool
299+ Name="VCResourceCompilerTool"
300+ PreprocessorDefinitions="NDEBUG"
301+ Culture="1033"
302+ />
303+ <Tool
304+ Name="VCPreLinkEventTool"
305+ />
306+ <Tool
307+ Name="VCLinkerTool"
308+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
309+ OutputFile="$(OutDir)/png2bmp.exe"
310+ LinkIncremental="1"
311+ SuppressStartupBanner="true"
312+ SubSystem="1"
313+ />
314+ <Tool
315+ Name="VCALinkTool"
316+ />
317+ <Tool
318+ Name="VCManifestTool"
319+ />
320+ <Tool
321+ Name="VCXDCMakeTool"
322+ />
323+ <Tool
324+ Name="VCBscMakeTool"
325+ SuppressStartupBanner="true"
326+ OutputFile=".\Release/png2bmp.bsc"
327+ />
328+ <Tool
329+ Name="VCFxCopTool"
330+ />
331+ <Tool
332+ Name="VCAppVerifierTool"
333+ />
334+ <Tool
335+ Name="VCPostBuildEventTool"
336+ />
337+ </Configuration>
338+ </Configurations>
339+ <References>
340+ </References>
341+ <Files>
342+ <File
343+ RelativePath="png2bmp.c"
344+ >
345+ <FileConfiguration
346+ Name="Release|Win32"
347+ >
348+ <Tool
349+ Name="VCCLCompilerTool"
350+ AdditionalIncludeDirectories=""
351+ PreprocessorDefinitions=""
352+ />
353+ </FileConfiguration>
354+ <FileConfiguration
355+ Name="Debug|Win32"
356+ >
357+ <Tool
358+ Name="VCCLCompilerTool"
359+ AdditionalIncludeDirectories=""
360+ PreprocessorDefinitions=""
361+ />
362+ </FileConfiguration>
363+ <FileConfiguration
364+ Name="DebugU|Win32"
365+ >
366+ <Tool
367+ Name="VCCLCompilerTool"
368+ AdditionalIncludeDirectories=""
369+ PreprocessorDefinitions=""
370+ />
371+ </FileConfiguration>
372+ <FileConfiguration
373+ Name="ReleaseU|Win32"
374+ >
375+ <Tool
376+ Name="VCCLCompilerTool"
377+ AdditionalIncludeDirectories=""
378+ PreprocessorDefinitions=""
379+ />
380+ </FileConfiguration>
381+ </File>
382+ </Files>
383+ <Globals>
384+ </Globals>
385+</VisualStudioProject>
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.c
--- a/pngdib.c Sat Jan 18 04:23:01 2014 +0000
+++ b/pngdib.c Sat Jan 18 04:24:47 2014 +0000
@@ -16,10 +16,10 @@
1616
1717 #define PNGDIB_INTERNALS
1818 #include "pngdib.h"
19-
19+#include <strsafe.h>
2020
21-#define PNGDIB_SRC_VERSION 30001
22-#define PNGDIB_SRC_VERSION_STRING _T("3.0.1")
21+#define PNGDIB_SRC_VERSION 30002
22+#define PNGDIB_SRC_VERSION_STRING _T("3.0.2")
2323
2424
2525 #if PNGDIB_SRC_VERSION != PNGDIB_HEADER_VERSION
@@ -41,25 +41,23 @@
4141 // user-configurable screen gamma.
4242 //static const double screen_gamma = 2.2;
4343
44-#define MAX_ERRMSGLEN 100
45-
4644 struct errstruct {
4745 jmp_buf *jbufp;
4846 TCHAR *errmsg;
4947 };
5048
51-static void pngd_get_error_message(int rv,TCHAR *e)
49+static void pngd_get_error_message(int rv,TCHAR *e, int e_len)
5250 {
5351 switch(rv) {
54- case PNGD_E_ERROR: lstrcpy(e,_T("Unknown error")); break;
55- case PNGD_E_VERSION: lstrcpy(e,_T("Incompatible library version")); break;
56- case PNGD_E_NOMEM: lstrcpy(e,_T("Unable to allocate memory")); break;
57- case PNGD_E_UNSUPP: lstrcpy(e,_T("Invalid or unsupported image")); break;
58- case PNGD_E_LIBPNG: lstrcpy(e,_T("libpng reported an error")); break;
59- case PNGD_E_BADBMP: lstrcpy(e,_T("Invalid BMP image")); break;
60- case PNGD_E_BADPNG: lstrcpy(e,_T("Invalid PNG image")); break;
61- case PNGD_E_READ: lstrcpy(e,_T("Unable to read file")); break;
62- case PNGD_E_WRITE: lstrcpy(e,_T("Unable to write file")); break;
52+ case PNGD_E_ERROR: StringCchCopy(e,e_len,_T("Unknown error")); break;
53+ case PNGD_E_VERSION: StringCchCopy(e,e_len,_T("Incompatible library version")); break;
54+ case PNGD_E_NOMEM: StringCchCopy(e,e_len,_T("Unable to allocate memory")); break;
55+ case PNGD_E_UNSUPP: StringCchCopy(e,e_len,_T("Invalid or unsupported image")); break;
56+ case PNGD_E_LIBPNG: StringCchCopy(e,e_len,_T("libpng reported an error")); break;
57+ case PNGD_E_BADBMP: StringCchCopy(e,e_len,_T("Invalid BMP image")); break;
58+ case PNGD_E_BADPNG: StringCchCopy(e,e_len,_T("Invalid PNG image")); break;
59+ case PNGD_E_READ: StringCchCopy(e,e_len,_T("Unable to read file")); break;
60+ case PNGD_E_WRITE: StringCchCopy(e,e_len,_T("Unable to write file")); break;
6361 }
6462 }
6563
@@ -132,12 +130,11 @@
132130 j = errinfop->jbufp;
133131
134132 #ifdef _UNICODE
135- _snwprintf(errinfop->errmsg,MAX_ERRMSGLEN,_T("[libpng] %S"),err_msg);
133+ StringCchPrintf(errinfop->errmsg,PNGDIB_ERRMSG_MAX,_T("[libpng] %S"),err_msg);
136134 #else
137- _snprintf(errinfop->errmsg,MAX_ERRMSGLEN,"[libpng] %s",err_msg);
135+ StringCchPrintf(errinfop->errmsg,PNGDIB_ERRMSG_MAX,"[libpng] %s",err_msg);
138136 #endif
139137
140- errinfop->errmsg[MAX_ERRMSGLEN-1]='\0';
141138 longjmp(*j, -1);
142139 }
143140
@@ -245,7 +242,7 @@
245242 row_pointers=NULL;
246243 lpdib=NULL;
247244
248- lstrcpy(p2d->common.errmsg,_T(""));
245+ StringCchCopy(p2d->common.errmsg,PNGDIB_ERRMSG_MAX,_T(""));
249246
250247 if(p2d->use_custom_bg_flag) {
251248 bkgd_color.red= p2d->bgcolor.red;
@@ -268,6 +265,9 @@
268265 my_png_error_fn, my_png_warning_fn);
269266 if(!png_ptr) { rv=PNGD_E_NOMEM; goto abort; }
270267
268+ if(p2d->common.pngptrhook_function) {
269+ (*(p2d->common.pngptrhook_function))(p2d->common.userdata,(void*)png_ptr);
270+ }
271271
272272 info_ptr = png_create_info_struct(png_ptr);
273273 if(!info_ptr) {
@@ -286,7 +286,7 @@
286286 if(p2d->input_method==0) {
287287 // reading from a filename
288288 if(!p2d->input_filename) {
289- wsprintf(p2d->common.errmsg,_T("Input filename not set"));
289+ StringCchPrintf(p2d->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Input filename not set"));
290290 rv=PNGD_E_ERROR; goto abort;
291291 }
292292
@@ -691,7 +691,7 @@
691691 // If we don't have an error message yet, use a
692692 // default one based on the code
693693 if(!lstrlen(p2d->common.errmsg)) {
694- pngd_get_error_message(rv,p2d->common.errmsg);
694+ pngd_get_error_message(rv,p2d->common.errmsg,PNGDIB_ERRMSG_MAX);
695695 }
696696
697697 return rv;
@@ -769,15 +769,15 @@
769769 newimage=NULL;
770770 dib_alpha32=0;
771771
772- lstrcpy(d2p->common.errmsg,_T(""));
772+ StringCchCopy(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T(""));
773773
774774 if(!d2p->output_filename) {
775- wsprintf(d2p->common.errmsg,_T("Output filename not set"));
775+ StringCchCopy(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Output filename not set"));
776776 rv=PNGD_E_ERROR; goto abort;
777777 }
778778
779779 if(!d2p->pdib) {
780- wsprintf(d2p->common.errmsg,_T("Input DIB not set"));
780+ StringCchCopy(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Input DIB not set"));
781781 rv=PNGD_E_ERROR; goto abort;
782782 }
783783
@@ -785,7 +785,7 @@
785785 headersize= d2p->pdib->biSize;
786786
787787 if(headersize<40 && headersize!=12) {
788- wsprintf(d2p->common.errmsg,_T("Unexpected BMP header size (%d)"),headersize);
788+ StringCchPrintf(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Unexpected BMP header size (%d)"),headersize);
789789 rv=PNGD_E_BADBMP; goto abort;
790790 }
791791
@@ -825,7 +825,7 @@
825825
826826 // sanity check
827827 if(height<1 || height>1000000 || width<1 || width>1000000) {
828- wsprintf(d2p->common.errmsg,_T("Unreasonable image dimensions (%dx%d)"),width,height);
828+ StringCchPrintf(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Unreasonable image dimensions (%dx%d)"),width,height);
829829 rv=PNGD_E_BADBMP; goto abort;
830830 }
831831
@@ -839,7 +839,7 @@
839839 if(dib_bpp!=1 && dib_bpp!=4 && dib_bpp!=8 && dib_bpp!=16
840840 && dib_bpp!=24 && dib_bpp!=32)
841841 {
842- wsprintf(d2p->common.errmsg,_T("Unsupported bit depth (%d)"),dib_bpp);
842+ StringCchPrintf(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Unsupported bit depth (%d)"),dib_bpp);
843843 rv=PNGD_E_UNSUPP; goto abort;
844844 }
845845 break;
@@ -859,7 +859,7 @@
859859 }
860860 break;
861861 default:
862- wsprintf(d2p->common.errmsg,_T("Unsupported compression scheme"));
862+ StringCchCopy(d2p->common.errmsg,PNGDIB_ERRMSG_MAX,_T("Unsupported compression scheme"));
863863 return PNGD_E_UNSUPP;
864864 }
865865
@@ -937,6 +937,9 @@
937937 my_png_error_fn, my_png_warning_fn);
938938 if (!png_ptr) { rv=PNGD_E_NOMEM; goto abort; }
939939
940+ if(d2p->common.pngptrhook_function) {
941+ (*(d2p->common.pngptrhook_function))(d2p->common.userdata,(void*)png_ptr);
942+ }
940943
941944 info_ptr = png_create_info_struct(png_ptr);
942945 if (!info_ptr) {
@@ -1111,7 +1114,7 @@
11111114 // If we don't have an error message yet, use a
11121115 // default one based on the code
11131116 if(!lstrlen(d2p->common.errmsg)) {
1114- pngd_get_error_message(rv,d2p->common.errmsg);
1117+ pngd_get_error_message(rv,d2p->common.errmsg,PNGDIB_ERRMSG_MAX);
11151118 }
11161119 return rv;
11171120 }
@@ -1203,7 +1206,7 @@
12031206 // The software id is never stored as UNICODE.
12041207 #ifdef _UNICODE
12051208 d2p->software_id_string = calloc(len+10,1);
1206- _snprintf(d2p->software_id_string,len+10,"%S",s);
1209+ StringCchPrintfA(d2p->software_id_string,len+10,"%S",s);
12071210 #else
12081211 d2p->software_id_string = _strdup(s);
12091212 #endif
@@ -1255,6 +1258,11 @@
12551258 qq->realloc_function = reallocfunc;
12561259 }
12571260
1261+void PNGDIB_DECL pngdib_setcallback_pngptrhook(PNGDIB *qq,
1262+ pngdib_pngptrhook_cb_type pngptrhookfn)
1263+{
1264+ qq->pngptrhook_function = pngptrhookfn;
1265+}
12581266
12591267 TCHAR* PNGDIB_DECL pngdib_get_error_msg(PNGDIB *qq)
12601268 {
@@ -1544,7 +1552,7 @@
15441552
15451553 if(p2dp->errmsg) {
15461554 msg=pngdib_get_error_msg(qq);
1547- lstrcpyn(p2dp->errmsg,msg,100);
1555+ lstrcpyn(p2dp->errmsg,msg,PNGDIB_ERRMSG_MAX);
15481556 }
15491557
15501558 pngdib_done(qq);
@@ -1584,7 +1592,7 @@
15841592
15851593 if(d2pp->errmsg) {
15861594 msg=pngdib_get_error_msg(qq);
1587- lstrcpyn(d2pp->errmsg,msg,100);
1595+ lstrcpyn(d2pp->errmsg,msg,PNGDIB_ERRMSG_MAX);
15881596 }
15891597
15901598 pngdib_done(qq);
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.dsp
--- a/pngdib.dsp Sat Jan 18 04:23:01 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
1-# Microsoft Developer Studio Project File - Name="pngdib" - Package Owner=<4>
2-# Microsoft Developer Studio Generated Build File, Format Version 6.00
3-# ** DO NOT EDIT **
4-
5-# TARGTYPE "Win32 (x86) Static Library" 0x0104
6-
7-CFG=pngdib - Win32 Unicode Debug
8-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9-!MESSAGE use the Export Makefile command and run
10-!MESSAGE
11-!MESSAGE NMAKE /f "pngdib.mak".
12-!MESSAGE
13-!MESSAGE You can specify a configuration when running NMAKE
14-!MESSAGE by defining the macro CFG on the command line. For example:
15-!MESSAGE
16-!MESSAGE NMAKE /f "pngdib.mak" CFG="pngdib - Win32 Unicode Debug"
17-!MESSAGE
18-!MESSAGE Possible choices for configuration are:
19-!MESSAGE
20-!MESSAGE "pngdib - Win32 Release" (based on "Win32 (x86) Static Library")
21-!MESSAGE "pngdib - Win32 Debug" (based on "Win32 (x86) Static Library")
22-!MESSAGE "pngdib - Win32 Unicode Debug" (based on "Win32 (x86) Static Library")
23-!MESSAGE
24-
25-# Begin Project
26-# PROP AllowPerConfigDependencies 0
27-# PROP Scc_ProjName ""
28-# PROP Scc_LocalPath ""
29-CPP=cl.exe
30-RSC=rc.exe
31-
32-!IF "$(CFG)" == "pngdib - Win32 Release"
33-
34-# PROP BASE Use_MFC 0
35-# PROP BASE Use_Debug_Libraries 0
36-# PROP BASE Output_Dir "Release"
37-# PROP BASE Intermediate_Dir "Release"
38-# PROP BASE Target_Dir ""
39-# PROP Use_MFC 0
40-# PROP Use_Debug_Libraries 0
41-# PROP Output_Dir "Release"
42-# PROP Intermediate_Dir "Release"
43-# PROP Target_Dir ""
44-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
45-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\libpng-1.2.5" /I "..\zlib-1.1.4" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
46-# ADD BASE RSC /l 0x409
47-# ADD RSC /l 0x409
48-BSC32=bscmake.exe
49-# ADD BASE BSC32 /nologo
50-# ADD BSC32 /nologo
51-LIB32=link.exe -lib
52-# ADD BASE LIB32 /nologo
53-# ADD LIB32 /nologo
54-
55-!ELSEIF "$(CFG)" == "pngdib - Win32 Debug"
56-
57-# PROP BASE Use_MFC 0
58-# PROP BASE Use_Debug_Libraries 1
59-# PROP BASE Output_Dir "Debug"
60-# PROP BASE Intermediate_Dir "Debug"
61-# PROP BASE Target_Dir ""
62-# PROP Use_MFC 0
63-# PROP Use_Debug_Libraries 1
64-# PROP Output_Dir "Debug"
65-# PROP Intermediate_Dir "Debug"
66-# PROP Target_Dir ""
67-# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
68-# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\libpng-1.2.5" /I "..\zlib-1.1.4" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
69-# ADD BASE RSC /l 0x409
70-# ADD RSC /l 0x409
71-BSC32=bscmake.exe
72-# ADD BASE BSC32 /nologo
73-# ADD BSC32 /nologo
74-LIB32=link.exe -lib
75-# ADD BASE LIB32 /nologo
76-# ADD LIB32 /nologo
77-
78-!ELSEIF "$(CFG)" == "pngdib - Win32 Unicode Debug"
79-
80-# PROP BASE Use_MFC 0
81-# PROP BASE Use_Debug_Libraries 1
82-# PROP BASE Output_Dir "pngdib___Win32_Unicode_Debug"
83-# PROP BASE Intermediate_Dir "pngdib___Win32_Unicode_Debug"
84-# PROP BASE Target_Dir ""
85-# PROP Use_MFC 0
86-# PROP Use_Debug_Libraries 1
87-# PROP Output_Dir "DebugU"
88-# PROP Intermediate_Dir "DebugU"
89-# PROP Target_Dir ""
90-# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\libpng-1.2.5" /I "..\zlib-1.1.4" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
91-# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\libpng-1.2.5" /I "..\zlib-1.1.4" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "UNICODE" /D "_UNICODE" /FR /YX /FD /c
92-# ADD BASE RSC /l 0x409
93-# ADD RSC /l 0x409
94-BSC32=bscmake.exe
95-# ADD BASE BSC32 /nologo
96-# ADD BSC32 /nologo
97-LIB32=link.exe -lib
98-# ADD BASE LIB32 /nologo
99-# ADD LIB32 /nologo
100-
101-!ENDIF
102-
103-# Begin Target
104-
105-# Name "pngdib - Win32 Release"
106-# Name "pngdib - Win32 Debug"
107-# Name "pngdib - Win32 Unicode Debug"
108-# Begin Source File
109-
110-SOURCE=.\pngdib.c
111-# End Source File
112-# Begin Source File
113-
114-SOURCE=.\pngdib.h
115-# End Source File
116-# End Target
117-# End Project
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.dsw
--- a/pngdib.dsw Sat Jan 18 04:23:01 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
1-Microsoft Developer Studio Workspace File, Format Version 6.00
2-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3-
4-###############################################################################
5-
6-Project: "bmp2png"=.\bmp2png\bmp2png.dsp - Package Owner=<4>
7-
8-Package=<5>
9-{{{
10-}}}
11-
12-Package=<4>
13-{{{
14- Begin Project Dependency
15- Project_Dep_Name pngdib
16- End Project Dependency
17-}}}
18-
19-###############################################################################
20-
21-Project: "png2bmp"=.\png2bmp\png2bmp.dsp - Package Owner=<4>
22-
23-Package=<5>
24-{{{
25-}}}
26-
27-Package=<4>
28-{{{
29- Begin Project Dependency
30- Project_Dep_Name pngdib
31- End Project Dependency
32-}}}
33-
34-###############################################################################
35-
36-Project: "pngdib"=.\pngdib.dsp - Package Owner=<4>
37-
38-Package=<5>
39-{{{
40-}}}
41-
42-Package=<4>
43-{{{
44-}}}
45-
46-###############################################################################
47-
48-Project: "smview"=.\smview\smview.dsp - Package Owner=<4>
49-
50-Package=<5>
51-{{{
52-}}}
53-
54-Package=<4>
55-{{{
56- Begin Project Dependency
57- Project_Dep_Name pngdib
58- End Project Dependency
59-}}}
60-
61-###############################################################################
62-
63-Global:
64-
65-Package=<5>
66-{{{
67-}}}
68-
69-Package=<3>
70-{{{
71-}}}
72-
73-###############################################################################
74-
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.h
--- a/pngdib.h Sat Jan 18 04:23:01 2014 +0000
+++ b/pngdib.h Sat Jan 18 04:24:47 2014 +0000
@@ -20,7 +20,7 @@
2020 #define PNGDIB_V2COMPATIBLE 1
2121 #endif
2222
23-#define PNGDIB_HEADER_VERSION 30001
23+#define PNGDIB_HEADER_VERSION 30002
2424
2525
2626 #define PNGDIB_DEFAULT_SCREEN_GAMMA 2.20000
@@ -135,6 +135,7 @@
135135 typedef void* (PNGDIB_DECL *pngdib_malloc_cb_type)(void *userdata, int memblksize);
136136 typedef void (PNGDIB_DECL *pngdib_free_cb_type)(void *userdata, void *memblk);
137137 typedef void* (PNGDIB_DECL *pngdib_realloc_cb_type)(void *userdata, void *memblk, int memblksize);
138+typedef void (PNGDIB_DECL *pngdib_pngptrhook_cb_type)(void *userdata, void *pngptr);
138139
139140 struct pngdib_common_struct;
140141 typedef struct pngdib_common_struct PNGDIB;
@@ -158,6 +159,7 @@
158159 pngdib_malloc_cb_type malloc_function;
159160 pngdib_free_cb_type free_function;
160161 pngdib_realloc_cb_type realloc_function;
162+ pngdib_pngptrhook_cb_type pngptrhook_function;
161163 int dib_alpha32;
162164 };
163165
@@ -210,9 +212,6 @@
210212 int bgcolor_returned;
211213 };
212214
213-#undef _PNGD_DEFINE_COMMON_FIELDS
214-
215-
216215 #endif // PNGDIB_INTERNALS
217216
218217 ///////////// d2p functions
@@ -272,6 +271,9 @@
272271 pngdib_free_cb_type freefunc,
273272 pngdib_realloc_cb_type reallocfunc);
274273
274+PNGDIB_EXT void PNGDIB_DECL pngdib_setcallback_pngptrhook(PNGDIB *xx,
275+ pngdib_pngptrhook_cb_type pngptrhookfn);
276+
275277 PNGDIB_EXT void PNGDIB_DECL pngdib_set_userdata(PNGDIB *xx, void *userdata);
276278 PNGDIB_EXT void* PNGDIB_DECL pngdib_get_userdata(PNGDIB *xx);
277279 PNGDIB_EXT TCHAR* PNGDIB_DECL pngdib_get_error_msg(PNGDIB *xx);
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.sln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pngdib.sln Sat Jan 18 04:24:47 2014 +0000
@@ -0,0 +1,60 @@
1+
2+Microsoft Visual Studio Solution File, Format Version 10.00
3+# Visual C++ Express 2008
4+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bmp2png", "bmp2png\bmp2png.vcproj", "{AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}"
5+ ProjectSection(ProjectDependencies) = postProject
6+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5} = {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}
7+ EndProjectSection
8+EndProject
9+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "png2bmp", "png2bmp\png2bmp.vcproj", "{51736FCB-5C13-419E-BC85-974FCE62E4E1}"
10+ ProjectSection(ProjectDependencies) = postProject
11+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5} = {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}
12+ EndProjectSection
13+EndProject
14+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pngdib", "pngdib.vcproj", "{0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}"
15+EndProject
16+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smview", "smview\smview.vcproj", "{56ADDE9B-629D-4C52-8BEA-181BFAAD4740}"
17+ ProjectSection(ProjectDependencies) = postProject
18+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5} = {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}
19+ EndProjectSection
20+EndProject
21+Global
22+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
23+ Debug|Win32 = Debug|Win32
24+ DebugU|Win32 = DebugU|Win32
25+ Release|Win32 = Release|Win32
26+ ReleaseU|Win32 = ReleaseU|Win32
27+ EndGlobalSection
28+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.Debug|Win32.ActiveCfg = Debug|Win32
30+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.Debug|Win32.Build.0 = Debug|Win32
31+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.DebugU|Win32.ActiveCfg = DebugU|Win32
32+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.Release|Win32.ActiveCfg = Release|Win32
33+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.Release|Win32.Build.0 = Release|Win32
34+ {AC6F7F5B-ECE7-4A5D-BA3A-EE254E9C5904}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
35+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.Debug|Win32.ActiveCfg = Debug|Win32
36+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.Debug|Win32.Build.0 = Debug|Win32
37+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.DebugU|Win32.ActiveCfg = DebugU|Win32
38+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.Release|Win32.ActiveCfg = Release|Win32
39+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.Release|Win32.Build.0 = Release|Win32
40+ {51736FCB-5C13-419E-BC85-974FCE62E4E1}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
41+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.Debug|Win32.ActiveCfg = Debug|Win32
42+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.Debug|Win32.Build.0 = Debug|Win32
43+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.DebugU|Win32.ActiveCfg = DebugU|Win32
44+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.DebugU|Win32.Build.0 = DebugU|Win32
45+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.Release|Win32.ActiveCfg = Release|Win32
46+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.Release|Win32.Build.0 = Release|Win32
47+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
48+ {0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}.ReleaseU|Win32.Build.0 = ReleaseU|Win32
49+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.Debug|Win32.ActiveCfg = Debug|Win32
50+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.Debug|Win32.Build.0 = Debug|Win32
51+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.DebugU|Win32.ActiveCfg = DebugU|Win32
52+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.DebugU|Win32.Build.0 = DebugU|Win32
53+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.Release|Win32.ActiveCfg = Release|Win32
54+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.Release|Win32.Build.0 = Release|Win32
55+ {56ADDE9B-629D-4C52-8BEA-181BFAAD4740}.ReleaseU|Win32.ActiveCfg = ReleaseU|Win32
56+ EndGlobalSection
57+ GlobalSection(SolutionProperties) = preSolution
58+ HideSolutionNode = FALSE
59+ EndGlobalSection
60+EndGlobal
diff -r d318a549c7e1 -r 01ac235d4a64 pngdib.vcproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pngdib.vcproj Sat Jan 18 04:24:47 2014 +0000
@@ -0,0 +1,337 @@
1+<?xml version="1.0" encoding="Windows-1252"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="9.00"
5+ Name="pngdib"
6+ ProjectGUID="{0C0165C0-A9AB-4E38-A9CF-6921291E6AC5}"
7+ RootNamespace="pngdib"
8+ TargetFrameworkVersion="0"
9+ >
10+ <Platforms>
11+ <Platform
12+ Name="Win32"
13+ />
14+ </Platforms>
15+ <ToolFiles>
16+ </ToolFiles>
17+ <Configurations>
18+ <Configuration
19+ Name="Release|Win32"
20+ OutputDirectory="$(ConfigurationName)"
21+ IntermediateDirectory="$(ConfigurationName)"
22+ ConfigurationType="4"
23+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
24+ UseOfMFC="0"
25+ ATLMinimizesCRunTimeLibraryUsage="false"
26+ CharacterSet="2"
27+ >
28+ <Tool
29+ Name="VCPreBuildEventTool"
30+ />
31+ <Tool
32+ Name="VCCustomBuildTool"
33+ />
34+ <Tool
35+ Name="VCXMLDataGeneratorTool"
36+ />
37+ <Tool
38+ Name="VCWebServiceProxyGeneratorTool"
39+ />
40+ <Tool
41+ Name="VCMIDLTool"
42+ />
43+ <Tool
44+ Name="VCCLCompilerTool"
45+ Optimization="2"
46+ AdditionalIncludeDirectories="..\libpng-1.4.1,..\zlib-1.2.3"
47+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
48+ RuntimeLibrary="0"
49+ WarningLevel="3"
50+ SuppressStartupBanner="true"
51+ />
52+ <Tool
53+ Name="VCManagedResourceCompilerTool"
54+ />
55+ <Tool
56+ Name="VCResourceCompilerTool"
57+ Culture="1033"
58+ />
59+ <Tool
60+ Name="VCPreLinkEventTool"
61+ />
62+ <Tool
63+ Name="VCLibrarianTool"
64+ OutputFile="$(OutDir)\pngdib.lib"
65+ SuppressStartupBanner="true"
66+ />
67+ <Tool
68+ Name="VCALinkTool"
69+ />
70+ <Tool
71+ Name="VCXDCMakeTool"
72+ />
73+ <Tool
74+ Name="VCBscMakeTool"
75+ SuppressStartupBanner="true"
76+ />
77+ <Tool
78+ Name="VCFxCopTool"
79+ />
80+ <Tool
81+ Name="VCPostBuildEventTool"
82+ />
83+ </Configuration>
84+ <Configuration
85+ Name="Debug|Win32"
86+ OutputDirectory="$(ConfigurationName)"
87+ IntermediateDirectory="$(ConfigurationName)"
88+ ConfigurationType="4"
89+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
90+ UseOfMFC="0"
91+ ATLMinimizesCRunTimeLibraryUsage="false"
92+ CharacterSet="2"
93+ >
94+ <Tool
95+ Name="VCPreBuildEventTool"
96+ />
97+ <Tool
98+ Name="VCCustomBuildTool"
99+ />
100+ <Tool
101+ Name="VCXMLDataGeneratorTool"
102+ />
103+ <Tool
104+ Name="VCWebServiceProxyGeneratorTool"
105+ />
106+ <Tool
107+ Name="VCMIDLTool"
108+ />
109+ <Tool
110+ Name="VCCLCompilerTool"
111+ Optimization="0"
112+ AdditionalIncludeDirectories="..\libpng-1.4.1,..\zlib-1.2.3"
113+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
114+ RuntimeLibrary="1"
115+ BrowseInformation="1"
116+ WarningLevel="3"
117+ SuppressStartupBanner="true"
118+ DebugInformationFormat="1"
119+ />
120+ <Tool
121+ Name="VCManagedResourceCompilerTool"
122+ />
123+ <Tool
124+ Name="VCResourceCompilerTool"
125+ Culture="1033"
126+ />
127+ <Tool
128+ Name="VCPreLinkEventTool"
129+ />
130+ <Tool
131+ Name="VCLibrarianTool"
132+ OutputFile="$(OutDir)\pngdib.lib"
133+ SuppressStartupBanner="true"
134+ />
135+ <Tool
136+ Name="VCALinkTool"
137+ />
138+ <Tool
139+ Name="VCXDCMakeTool"
140+ />
141+ <Tool
142+ Name="VCBscMakeTool"
143+ SuppressStartupBanner="true"
144+ />
145+ <Tool
146+ Name="VCFxCopTool"
147+ />
148+ <Tool
149+ Name="VCPostBuildEventTool"
150+ />
151+ </Configuration>
152+ <Configuration
153+ Name="DebugU|Win32"
154+ OutputDirectory="$(ConfigurationName)"
155+ IntermediateDirectory="$(ConfigurationName)"
156+ ConfigurationType="4"
157+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
158+ UseOfMFC="0"
159+ ATLMinimizesCRunTimeLibraryUsage="false"
160+ CharacterSet="1"
161+ >
162+ <Tool
163+ Name="VCPreBuildEventTool"
164+ />
165+ <Tool
166+ Name="VCCustomBuildTool"
167+ />
168+ <Tool
169+ Name="VCXMLDataGeneratorTool"
170+ />
171+ <Tool
172+ Name="VCWebServiceProxyGeneratorTool"
173+ />
174+ <Tool
175+ Name="VCMIDLTool"
176+ />
177+ <Tool
178+ Name="VCCLCompilerTool"
179+ Optimization="0"
180+ AdditionalIncludeDirectories="..\libpng-1.4.1,..\zlib-1.2.3"
181+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
182+ RuntimeLibrary="1"
183+ BrowseInformation="1"
184+ WarningLevel="3"
185+ SuppressStartupBanner="true"
186+ DebugInformationFormat="1"
187+ />
188+ <Tool
189+ Name="VCManagedResourceCompilerTool"
190+ />
191+ <Tool
192+ Name="VCResourceCompilerTool"
193+ Culture="1033"
194+ />
195+ <Tool
196+ Name="VCPreLinkEventTool"
197+ />
198+ <Tool
199+ Name="VCLibrarianTool"
200+ OutputFile="$(OutDir)\pngdib.lib"
201+ SuppressStartupBanner="true"
202+ />
203+ <Tool
204+ Name="VCALinkTool"
205+ />
206+ <Tool
207+ Name="VCXDCMakeTool"
208+ />
209+ <Tool
210+ Name="VCBscMakeTool"
211+ SuppressStartupBanner="true"
212+ />
213+ <Tool
214+ Name="VCFxCopTool"
215+ />
216+ <Tool
217+ Name="VCPostBuildEventTool"
218+ />
219+ </Configuration>
220+ <Configuration
221+ Name="ReleaseU|Win32"
222+ OutputDirectory="$(ConfigurationName)"
223+ IntermediateDirectory="$(ConfigurationName)"
224+ ConfigurationType="4"
225+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
226+ UseOfMFC="0"
227+ ATLMinimizesCRunTimeLibraryUsage="false"
228+ CharacterSet="1"
229+ >
230+ <Tool
231+ Name="VCPreBuildEventTool"
232+ />
233+ <Tool
234+ Name="VCCustomBuildTool"
235+ />
236+ <Tool
237+ Name="VCXMLDataGeneratorTool"
238+ />
239+ <Tool
240+ Name="VCWebServiceProxyGeneratorTool"
241+ />
242+ <Tool
243+ Name="VCMIDLTool"
244+ />
245+ <Tool
246+ Name="VCCLCompilerTool"
247+ Optimization="2"
248+ AdditionalIncludeDirectories="..\libpng-1.4.1,..\zlib-1.2.3"
249+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
250+ RuntimeLibrary="0"
251+ WarningLevel="3"
252+ SuppressStartupBanner="true"
253+ />
254+ <Tool
255+ Name="VCManagedResourceCompilerTool"
256+ />
257+ <Tool
258+ Name="VCResourceCompilerTool"
259+ Culture="1033"
260+ />
261+ <Tool
262+ Name="VCPreLinkEventTool"
263+ />
264+ <Tool
265+ Name="VCLibrarianTool"
266+ OutputFile="$(OutDir)\pngdib.lib"
267+ SuppressStartupBanner="true"
268+ />
269+ <Tool
270+ Name="VCALinkTool"
271+ />
272+ <Tool
273+ Name="VCXDCMakeTool"
274+ />
275+ <Tool
276+ Name="VCBscMakeTool"
277+ SuppressStartupBanner="true"
278+ />
279+ <Tool
280+ Name="VCFxCopTool"
281+ />
282+ <Tool
283+ Name="VCPostBuildEventTool"
284+ />
285+ </Configuration>
286+ </Configurations>
287+ <References>
288+ </References>
289+ <Files>
290+ <File
291+ RelativePath="pngdib.c"
292+ >
293+ <FileConfiguration
294+ Name="Release|Win32"
295+ >
296+ <Tool
297+ Name="VCCLCompilerTool"
298+ AdditionalIncludeDirectories=""
299+ PreprocessorDefinitions=""
300+ />
301+ </FileConfiguration>
302+ <FileConfiguration
303+ Name="Debug|Win32"
304+ >
305+ <Tool
306+ Name="VCCLCompilerTool"
307+ AdditionalIncludeDirectories=""
308+ PreprocessorDefinitions=""
309+ />
310+ </FileConfiguration>
311+ <FileConfiguration
312+ Name="DebugU|Win32"
313+ >
314+ <Tool
315+ Name="VCCLCompilerTool"
316+ AdditionalIncludeDirectories=""
317+ PreprocessorDefinitions=""
318+ />
319+ </FileConfiguration>
320+ <FileConfiguration
321+ Name="ReleaseU|Win32"
322+ >
323+ <Tool
324+ Name="VCCLCompilerTool"
325+ AdditionalIncludeDirectories=""
326+ PreprocessorDefinitions=""
327+ />
328+ </FileConfiguration>
329+ </File>
330+ <File
331+ RelativePath="pngdib.h"
332+ >
333+ </File>
334+ </Files>
335+ <Globals>
336+ </Globals>
337+</VisualStudioProject>
diff -r d318a549c7e1 -r 01ac235d4a64 readme.html
--- a/readme.html Sat Jan 18 04:23:01 2014 +0000
+++ b/readme.html Sat Jan 18 04:24:47 2014 +0000
@@ -23,8 +23,8 @@
2323 <p>
2424 A DIB-PNG conversion library for Win32<br>
2525 By Jason Summers &lt;<a href="mailto:jason1@pobox.com">jason1@pobox.com</a>&gt;<br>
26-Version 3.0.1, Mar. 2003<br>
27-Web site: &lt;<a href="http://pobox.com/~jason1/pngdib/">http://pobox.com/~jason1/pngdib/</a>&gt;
26+Version 3.0.2, Mar. 2010<br>
27+Web site: &lt;<a href="http://entropymine.com/jason/pngdib/">http://entropymine.com/jason/pngdib/</a>&gt;
2828 </p>
2929
3030 <p><tt>
@@ -42,13 +42,9 @@
4242 <h2>Requirements</h2>
4343
4444 <ul>
45-<li>zlib &lt;<a href="http://www.info-zip.org/pub/infozip/zlib/">http://www.info-zip.org/pub/infozip/zlib/</a>&gt;<br>
46-Tested with v1.1.4; other versions probably also work.
45+<li>zlib &lt;<a href="http://www.zlib.net/">http://www.zlib.net/</a>&gt;<br>
4746
4847 <li>libpng &lt;<a href="http://www.libpng.org/pub/png/">http://www.libpng.org/pub/png/</a>&gt;<br>
49-Version 1.2.2beta5 or higher recommended. Most earlier versions
50-will probably work, but they do not always handle gamma correction
51-correctly when combined with alpha transparency.
5248 </ul>
5349 </div>
5450
@@ -194,6 +190,17 @@
194190 allocates.
195191
196192
193+<dt>void <b>pngdib_setcallback_pngptrhook</b>(PNGDIB *xx,
194+ pngdib_pngptrhook_cb_type pngptrhookfn);<br>
195+<small>
196+&nbsp; typedef void (PNGDIB_DECL *pngdib_pngptrhook_cb_type)(void *userdata, void *pngptr);
197+</small>
198+<dd>Set a callback function to be called immediately after the main libpng object
199+has been created. Cast the "pngptr" param to a "png_structp" to use it.
200+Not recommended if you can avoid using it, but sometimes you need a way to
201+call png_set_user_limits() or similar functions.
202+
203+
197204 <dt>TCHAR* <b>pngdib_get_error_msg</b>(PNGDIB *xx);
198205 <dd>Returns a pointer to an error message reflecting the
199206 most recent error that occurred in pngdib_d2p_run or pndib_p2d_run.
@@ -395,6 +402,13 @@
395402 <div style="background-color:#ddf">
396403 <h2>History</h2>
397404
405+<h4>CHANGES in PNGDIB v3.0.2</h4>
406+<ul>
407+<li>New pngdib_setcallback_pngptrhook() function.
408+<li>Made the sample utilites (png2bmp, bmp2png, smview) support Unicode.
409+<li>Other minor cleanup of the sample utilities.
410+</ul>
411+
398412 <h4>CHANGES in PNGDIB v3.0.1 (vs. 3.0.0)</h4>
399413 <ul>
400414 <li>Re-fixed a memory-freeing error that I fixed in
@@ -436,9 +450,6 @@
436450
437451 <h2><a name=smview>Instructions for the sample PNG viewer (smview)</a></h2>
438452
439-<p>[This program is just a demo. For a more usable viewer, visit
440-<a href="http://pobox.com/~jason1/purpleview/">http://pobox.com/~jason1/purpleview/</a>.]</p>
441-
442453 <p>Load a PNG image by selecting File|Open from the menu, or by drag-and-drop
443454 from Windows Explorer.</p>
444455
diff -r d318a549c7e1 -r 01ac235d4a64 smview/smview.c
--- a/smview/smview.c Sat Jan 18 04:23:01 2014 +0000
+++ b/smview/smview.c Sat Jan 18 04:24:47 2014 +0000
@@ -9,30 +9,41 @@
99 */
1010
1111 #include <windows.h>
12+#include <tchar.h>
1213 #include <commdlg.h>
1314 #include <stdio.h>
15+#include <stdlib.h>
16+#include <malloc.h>
1417 #include "resource.h"
1518 #include <pngdib.h>
16-
17-#define MYNAME "Simple PNG Image Viewer"
18-#define SMVIEW_VERS "3.0.1"
19+#include <strsafe.h>
1920
20-HINSTANCE hInst;
21-LPBITMAPINFOHEADER lpdib;
22-int lpdib_size, lpdib_bits_offs;
23-void *lpbits;
24-int use_bkgd, use_custom_bg;
25-int use_gamma;
26-COLORREF custom_bg, image_bg;
27-int which_bg; /* 0==custom or default (depending on use_custom_bg) */
28- /* 1==image's */
29-char png_filename[MAX_PATH];
30-COLORREF g_custcolors[16];
21+#define MYNAME _T("Simple PNG Image Viewer")
22+#define SMVIEW_VERS _T("3.0.2")
23+#define SMVIEW_DATE _T("3/2010")
3124
32-LRESULT CALLBACK WndProcMain(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
33-BOOL CALLBACK DlgProcAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
25+struct globals_struct {
26+ HINSTANCE hInst;
27+ COLORREF custcolors[16];
28+ int use_bkgd, use_custom_bg;
29+ int use_gamma;
30+ COLORREF custom_bg, image_bg;
31+ int which_bg; /* 0==custom or default (depending on use_custom_bg) */
32+ /* 1==image's */
33+};
34+static struct globals_struct *g;
3435
35-int choose_color_dialog(HWND hwnd, COLORREF *color)
36+struct img_struct {
37+ LPBITMAPINFOHEADER dib;
38+ void *bits;
39+ TCHAR png_filename[MAX_PATH];
40+};
41+static struct img_struct *img;
42+
43+static LRESULT CALLBACK WndProcMain(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
44+static INT_PTR CALLBACK DlgProcAbout(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
45+
46+static int choose_color_dialog(HWND hwnd, COLORREF *color)
3647 {
3748 CHOOSECOLOR cc;
3849
@@ -40,7 +51,7 @@
4051 cc.lStructSize=sizeof(CHOOSECOLOR);
4152 cc.hwndOwner=hwnd;
4253 cc.rgbResult= *color; /* set initial value */
43- cc.lpCustColors=g_custcolors;
54+ cc.lpCustColors=g->custcolors;
4455 cc.Flags=CC_RGBINIT|CC_FULLOPEN;
4556
4657 if(ChooseColor(&cc)) {
@@ -50,14 +61,15 @@
5061 return 0;
5162 }
5263
53-int open_png_by_name(HWND hwnd, char *fn)
64+static int open_png_by_name(HWND hwnd, const TCHAR *fn)
5465 {
5566 PNGDIB *pngdib;
56- char buf[1000];
67+ TCHAR buf[1000];
5768 int ret;
5869 unsigned char bg_r, bg_g, bg_b;
70+ int dibsize, bits_offset;
5971
60- if(!strlen(fn)) {
72+ if(!lstrlen(fn)) {
6173 InvalidateRect(hwnd,NULL,TRUE);
6274 return 0;
6375 }
@@ -66,18 +78,18 @@
6678 if(!pngdib) return 0;
6779
6880 pngdib_p2d_set_png_filename(pngdib,fn);
69- pngdib_p2d_set_use_file_bg(pngdib,use_bkgd?1:0);
70- if(use_custom_bg) {
71- pngdib_p2d_set_custom_bg(pngdib,GetRValue(custom_bg),
72- GetGValue(custom_bg),GetBValue(custom_bg));
81+ pngdib_p2d_set_use_file_bg(pngdib,g->use_bkgd?1:0);
82+ if(g->use_custom_bg) {
83+ pngdib_p2d_set_custom_bg(pngdib,GetRValue(g->custom_bg),
84+ GetGValue(g->custom_bg),GetBValue(g->custom_bg));
7385 }
74- pngdib_p2d_set_gamma_correction(pngdib,use_gamma,PNGDIB_DEFAULT_SCREEN_GAMMA);
86+ pngdib_p2d_set_gamma_correction(pngdib,g->use_gamma,PNGDIB_DEFAULT_SCREEN_GAMMA);
7587
7688 ret=pngdib_p2d_run(pngdib);
7789
7890 if(ret) { /* returns 0 on success */
7991 SetForegroundWindow(hwnd);
80- sprintf(buf,"Cannot load image: %s (%d)",pngdib_get_error_msg(pngdib),ret);
92+ StringCbPrintf(buf,sizeof(buf),_T("Cannot load image: %s (%d)"),pngdib_get_error_msg(pngdib),ret);
8193 MessageBox(hwnd,buf,MYNAME,MB_OK|MB_ICONWARNING);
8294 InvalidateRect(hwnd,NULL,TRUE);
8395 pngdib_done(pngdib);
@@ -85,20 +97,20 @@
8597 }
8698
8799 /* get rid of previous image */
88- if(lpdib) { pngdib_p2d_free_dib(NULL,lpdib); lpdib=NULL; }
100+ if(img->dib) { pngdib_p2d_free_dib(NULL,img->dib); img->dib=NULL; }
89101
90- pngdib_p2d_get_dib(pngdib,&lpdib,&lpdib_size);
91- pngdib_p2d_get_dibbits(pngdib,&lpbits,&lpdib_bits_offs,NULL);
102+ pngdib_p2d_get_dib(pngdib,&img->dib,&dibsize);
103+ pngdib_p2d_get_dibbits(pngdib,&img->bits,&bits_offset,NULL);
92104
93105 InvalidateRect(hwnd,NULL,TRUE);
94- strcpy(png_filename,fn);
106+ StringCchCopy(img->png_filename,MAX_PATH,fn);
95107
96108 if(pngdib_p2d_get_bgcolor(pngdib,&bg_r,&bg_g,&bg_b)) {
97- image_bg = RGB(bg_r,bg_g,bg_b);
98- which_bg=1;
109+ g->image_bg = RGB(bg_r,bg_g,bg_b);
110+ g->which_bg=1;
99111 }
100112 else {
101- which_bg=0;
113+ g->which_bg=0;
102114 }
103115
104116 pngdib_done(pngdib);
@@ -106,20 +118,20 @@
106118 return 1;
107119 }
108120
109-int open_png_dialog(HWND hwnd)
121+static int open_png_dialog(HWND hwnd)
110122 {
111- char fn[MAX_PATH];
123+ TCHAR fn[MAX_PATH];
112124 OPENFILENAME ofn;
113125
114- strcpy(fn,"");
126+ StringCbCopy(fn,sizeof(fn),_T(""));
115127
116128 ZeroMemory(&ofn,sizeof(OPENFILENAME));
117129
118130 ofn.lStructSize=sizeof(OPENFILENAME);
119131 ofn.hwndOwner=hwnd;
120- ofn.lpstrFilter="PNG image (*.png)\0*.png\0All files\0*.*\0\0";
132+ ofn.lpstrFilter=_T("PNG image (*.png)\0*.png\0All files\0*.*\0\0");
121133 ofn.nFilterIndex=1;
122- ofn.lpstrTitle="Open PNG file";
134+ ofn.lpstrTitle=_T("Open PNG file");
123135
124136 ofn.lpstrInitialDir=NULL;
125137 ofn.lpstrFile=fn;
@@ -130,10 +142,10 @@
130142 return open_png_by_name(hwnd,fn);
131143 }
132144
133-void dropped_files(HWND hwnd, HDROP hDrop)
145+static void dropped_files(HWND hwnd, HDROP hDrop)
134146 {
135147 UINT ret;
136- char fn[MAX_PATH];
148+ TCHAR fn[MAX_PATH];
137149
138150 ret=DragQueryFile(hDrop,0xFFFFFFFF,NULL,0);
139151 if(ret==1) { /* number of files dropped */
@@ -143,41 +155,41 @@
143155 DragFinish(hDrop);
144156 }
145157
146-void save_as_png(HWND hwnd)
158+static void save_as_png(HWND hwnd)
147159 {
148160 PNGDIB *pngdib;
149161 int ret;
150162 OPENFILENAME ofn;
151- char fn[MAX_PATH];
152- char buf[200];
163+ TCHAR fn[MAX_PATH];
164+ TCHAR buf[200];
153165
154- strcpy(fn,png_filename);
166+ StringCbCopy(fn,sizeof(fn),img->png_filename);
155167
156168 ZeroMemory(&ofn,sizeof(OPENFILENAME));
157169 ofn.lStructSize=sizeof(OPENFILENAME);
158170 ofn.hwndOwner=hwnd;
159- ofn.lpstrFilter="PNG image (*.png)\0*.png\0\0";
171+ ofn.lpstrFilter=_T("PNG image (*.png)\0*.png\0\0");
160172 ofn.nFilterIndex=1;
161- ofn.lpstrTitle="Save As PNG";
173+ ofn.lpstrTitle=_T("Save As PNG");
162174
163175 ofn.lpstrInitialDir=NULL;
164176 ofn.lpstrFile=fn;
165177 ofn.nMaxFile=MAX_PATH;
166178 ofn.Flags=OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
167- ofn.lpstrDefExt="png";
179+ ofn.lpstrDefExt=_T("png");
168180
169181 if(!GetSaveFileName(&ofn)) return; /* canceled by user */
170182
171183 pngdib=pngdib_d2p_init();
172184 pngdib_d2p_set_png_filename(pngdib,fn);
173- pngdib_d2p_set_dib(pngdib,lpdib,0,NULL,0);
174- pngdib_d2p_set_software_id(pngdib,"SMVIEW");
175- pngdib_d2p_set_gamma_label(pngdib, use_gamma, PNGDIB_DEFAULT_FILE_GAMMA);
185+ pngdib_d2p_set_dib(pngdib,img->dib,0,NULL,0);
186+ pngdib_d2p_set_software_id(pngdib,_T("SMVIEW"));
187+ pngdib_d2p_set_gamma_label(pngdib, g->use_gamma, PNGDIB_DEFAULT_FILE_GAMMA);
176188
177189 ret=pngdib_d2p_run(pngdib);
178190
179191 if(ret) {
180- sprintf(buf,"Cannot save file: %s (%d)",pngdib_get_error_msg(pngdib),ret);
192+ StringCbPrintf(buf,sizeof(buf),_T("Cannot save file: %s (%d)"),pngdib_get_error_msg(pngdib),ret);
181193 MessageBox(hwnd,buf,MYNAME,MB_OK|MB_ICONWARNING);
182194 }
183195
@@ -188,49 +200,51 @@
188200 LPSTR lpCmdLine,int nCmdShow)
189201 {
190202 MSG msg;
191- WNDCLASS wc;
203+ WNDCLASS wc;
192204 HWND hwnd;
205+ int rv;
193206
194- lpdib=NULL;
195- use_bkgd=1; use_custom_bg=1; use_gamma=1;
196- strcpy(png_filename,"");
197- image_bg = RGB(255,255,255);
198- custom_bg = RGB(240,240,240);
199- which_bg=0;
200- ZeroMemory((void*)g_custcolors,16*sizeof(COLORREF));
207+ g=calloc(sizeof(struct globals_struct),1);
208+ img=calloc(sizeof(struct img_struct),1);
209+ if(!g || !img) return 0;
201210
202- hInst=hInstance;
203- hwnd=NULL;
211+ g->use_bkgd=1; g->use_custom_bg=1; g->use_gamma=1;
212+ g->image_bg = RGB(255,255,255);
213+ g->custom_bg = RGB(240,240,240);
214+ g->which_bg=0;
215+ g->hInst=hInstance;
216+ StringCbCopy(img->png_filename,MAX_PATH,_T(""));
204217
218+ ZeroMemory(&wc,sizeof(WNDCLASS));
205219 wc.style = CS_DBLCLKS;
206220 wc.lpfnWndProc = (WNDPROC)WndProcMain;
207- wc.cbClsExtra = 0;
208- wc.cbWndExtra = 0;
209- wc.hInstance = hInst;
210- wc.hIcon = LoadIcon(hInst,"ICONMAIN");
221+ wc.hInstance = g->hInst;
222+ wc.hIcon = LoadIcon(g->hInst,_T("ICONMAIN"));
211223 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
212- wc.hbrBackground = NULL;
213- wc.lpszMenuName = "MENUMAIN";
214- wc.lpszClassName = "SMVIEWCLASS";
224+ wc.lpszMenuName = _T("MENUMAIN");
225+ wc.lpszClassName = _T("SMVIEWCLASS");
215226 if(!RegisterClass(&wc)) return 0;
216227
217- hwnd = CreateWindow(
218- "SMVIEWCLASS",MYNAME,
219- WS_VISIBLE|WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
228+ hwnd = CreateWindow(_T("SMVIEWCLASS"),MYNAME,WS_VISIBLE|WS_OVERLAPPEDWINDOW,
220229 CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
221- NULL,NULL,hInst,NULL);
222- if (!hwnd) return 0;
230+ NULL,NULL,g->hInst,NULL);
231+ if(!hwnd) return 0;
223232
224233 DragAcceptFiles(hwnd,TRUE);
225234
226- while(GetMessage(&msg,NULL,0,0)){
235+ while(1)
236+ {
237+ rv=GetMessage(&msg,NULL,0,0);
238+ if(!rv || rv== -1) break;
227239 TranslateMessage(&msg);
228240 DispatchMessage(&msg);
229241 }
230- return (msg.wParam);
242+ free(img);
243+ free(g);
244+ return (int)msg.wParam;
231245 }
232246
233-LRESULT CALLBACK WndProcMain(HWND hwnd, UINT msg,
247+static LRESULT CALLBACK WndProcMain(HWND hwnd, UINT msg,
234248 WPARAM wParam, LPARAM lParam)
235249 {
236250 WORD id;
@@ -248,13 +262,13 @@
248262 delbrush=0;
249263 hdc=(HDC)wParam;
250264 if(!GetClientRect(hwnd,&rect)) return 0;
251- if(which_bg) {
252- br=CreateSolidBrush(image_bg);
265+ if(g->which_bg) {
266+ br=CreateSolidBrush(g->image_bg);
253267 delbrush=1;
254268 }
255269 else {
256- if(use_custom_bg) {
257- br=CreateSolidBrush(custom_bg);
270+ if(g->use_custom_bg) {
271+ br=CreateSolidBrush(g->custom_bg);
258272 delbrush=1;
259273 }
260274 else {
@@ -273,12 +287,12 @@
273287 PAINTSTRUCT paintStruct;
274288 HDC hdc;
275289
276- hdc = BeginPaint( hwnd, &paintStruct );
277- if(lpdib) {
290+ hdc = BeginPaint(hwnd, &paintStruct);
291+ if(img->dib) {
278292 StretchDIBits(hdc,
279- 0,0,lpdib->biWidth,lpdib->biHeight,
280- 0,0,lpdib->biWidth,lpdib->biHeight,
281- lpbits,(LPBITMAPINFO)lpdib,
293+ 0,0,img->dib->biWidth,img->dib->biHeight,
294+ 0,0,img->dib->biWidth,img->dib->biHeight,
295+ img->bits,(LPBITMAPINFO)img->dib,
282296 DIB_RGB_COLORS,SRCCOPY);
283297 }
284298 EndPaint(hwnd, &paintStruct);
@@ -286,7 +300,7 @@
286300 }
287301
288302 case WM_DESTROY:
289- if(lpdib) { pngdib_p2d_free_dib(NULL,lpdib); lpdib=NULL; }
303+ if(img->dib) { pngdib_p2d_free_dib(NULL,img->dib); img->dib=NULL; }
290304 PostQuitMessage(0);
291305 return 0;
292306
@@ -296,17 +310,17 @@
296310
297311 case WM_INITMENU:
298312 CheckMenuItem((HMENU)wParam, ID_BG_BKGD , MF_BYCOMMAND|
299- (use_bkgd?MF_CHECKED:MF_UNCHECKED) );
313+ (g->use_bkgd?MF_CHECKED:MF_UNCHECKED) );
300314 CheckMenuItem((HMENU)wParam, ID_BG_CUSTOM , MF_BYCOMMAND|
301- (use_custom_bg?MF_CHECKED:MF_UNCHECKED) );
315+ (g->use_custom_bg?MF_CHECKED:MF_UNCHECKED) );
302316 CheckMenuItem((HMENU)wParam, ID_GAMMACORRECT , MF_BYCOMMAND|
303- (use_gamma?MF_CHECKED:MF_UNCHECKED) );
317+ (g->use_gamma?MF_CHECKED:MF_UNCHECKED) );
304318 EnableMenuItem((HMENU)wParam, ID_CLOSE, MF_BYCOMMAND|
305- (lpdib?MF_ENABLED:MF_GRAYED) );
319+ (img->dib?MF_ENABLED:MF_GRAYED) );
306320 EnableMenuItem((HMENU)wParam, ID_SAVEASPNG, MF_BYCOMMAND|
307- (lpdib?MF_ENABLED:MF_GRAYED) );
321+ (img->dib?MF_ENABLED:MF_GRAYED) );
308322 EnableMenuItem((HMENU)wParam, ID_SAVEASBMP, MF_BYCOMMAND|
309- (lpdib?MF_ENABLED:MF_GRAYED) );
323+ (img->dib?MF_ENABLED:MF_GRAYED) );
310324 return 0;
311325
312326 case WM_COMMAND:
@@ -318,52 +332,52 @@
318332 open_png_dialog(hwnd);
319333 return 0;
320334 case ID_SAVEASPNG:
321- if(lpdib) save_as_png(hwnd);
335+ if(img->dib) save_as_png(hwnd);
322336 return 0;
323337 case ID_CLOSE:
324- if(lpdib) { pngdib_p2d_free_dib(NULL,lpdib); lpdib=NULL; }
325- strcpy(png_filename,"");
326- which_bg=0;
338+ if(img->dib) { pngdib_p2d_free_dib(NULL,img->dib); img->dib=NULL; }
339+ StringCchCopy(img->png_filename,MAX_PATH,_T(""));
340+ g->which_bg=0;
327341 InvalidateRect(hwnd,NULL,TRUE);
328342 return 0;
329343 case ID_BG_BKGD:
330- use_bkgd = !use_bkgd;
331- open_png_by_name(hwnd,png_filename); /* reload image */
344+ g->use_bkgd = !g->use_bkgd;
345+ open_png_by_name(hwnd,img->png_filename); /* reload image */
332346 return 0;
333347 case ID_BG_CUSTOM:
334- use_custom_bg = !use_custom_bg;
335- open_png_by_name(hwnd,png_filename);
348+ g->use_custom_bg = !g->use_custom_bg;
349+ open_png_by_name(hwnd,img->png_filename);
336350 return 0;
337351 case ID_GAMMACORRECT:
338- use_gamma = !use_gamma;
339- open_png_by_name(hwnd,png_filename);
352+ g->use_gamma = !g->use_gamma;
353+ open_png_by_name(hwnd,img->png_filename);
340354 return 0;
341355 case ID_SETBG:
342- if(choose_color_dialog(hwnd,&custom_bg)) {
343- open_png_by_name(hwnd,png_filename);
356+ if(choose_color_dialog(hwnd,&g->custom_bg)) {
357+ open_png_by_name(hwnd,img->png_filename);
344358 }
345359 return 0;
346360 case ID_ABOUT:
347- DialogBox(hInst,"ABOUTDLG",hwnd,DlgProcAbout);
361+ DialogBox(g->hInst,_T("ABOUTDLG"),hwnd,DlgProcAbout);
348362 return 0;
349363 }
350364 break;
351365 }
352- return (DefWindowProc(hwnd, msg, wParam, lParam));
366+ return DefWindowProc(hwnd, msg, wParam, lParam);
353367 }
354368
355-BOOL CALLBACK DlgProcAbout(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
369+static INT_PTR CALLBACK DlgProcAbout(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
356370 {
357371 WORD id;
358- char buf[1000];
372+ TCHAR buf[1000];
359373 id=LOWORD(wParam);
360374
361375 switch (msg) {
362376
363377 case WM_INITDIALOG:
364- sprintf(buf,"Demonstration PNG image viewer that uses the PNGDIB library.\r\n"
365- "Version %s\r\nBy Jason Summers, 8/2000-2/2003\r\nPNGDIB version %s",
366- SMVIEW_VERS,pngdib_get_version_string());
378+ StringCbPrintf(buf,sizeof(buf),_T("Demonstration PNG image viewer that uses the PNGDIB library.\r\n")
379+ _T("Version %s\r\nBy Jason Summers, 8/2000-%s\r\nPNGDIB version %s"),
380+ SMVIEW_VERS,SMVIEW_DATE,pngdib_get_version_string());
367381 SetDlgItemText(hwnd,IDC_TEXT1,buf);
368382
369383 return 1;
diff -r d318a549c7e1 -r 01ac235d4a64 smview/smview.dsp
--- a/smview/smview.dsp Sat Jan 18 04:23:01 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
1-# Microsoft Developer Studio Project File - Name="smview" - Package Owner=<4>
2-# Microsoft Developer Studio Generated Build File, Format Version 6.00
3-# ** DO NOT EDIT **
4-
5-# TARGTYPE "Win32 (x86) Application" 0x0101
6-
7-CFG=smview - Win32 Debug
8-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9-!MESSAGE use the Export Makefile command and run
10-!MESSAGE
11-!MESSAGE NMAKE /f "smview.mak".
12-!MESSAGE
13-!MESSAGE You can specify a configuration when running NMAKE
14-!MESSAGE by defining the macro CFG on the command line. For example:
15-!MESSAGE
16-!MESSAGE NMAKE /f "smview.mak" CFG="smview - Win32 Debug"
17-!MESSAGE
18-!MESSAGE Possible choices for configuration are:
19-!MESSAGE
20-!MESSAGE "smview - Win32 Release" (based on "Win32 (x86) Application")
21-!MESSAGE "smview - Win32 Debug" (based on "Win32 (x86) Application")
22-!MESSAGE
23-
24-# Begin Project
25-# PROP AllowPerConfigDependencies 0
26-# PROP Scc_ProjName ""
27-# PROP Scc_LocalPath ""
28-CPP=cl.exe
29-MTL=midl.exe
30-RSC=rc.exe
31-
32-!IF "$(CFG)" == "smview - Win32 Release"
33-
34-# PROP BASE Use_MFC 0
35-# PROP BASE Use_Debug_Libraries 0
36-# PROP BASE Output_Dir "Release"
37-# PROP BASE Intermediate_Dir "Release"
38-# PROP BASE Target_Dir ""
39-# PROP Use_MFC 0
40-# PROP Use_Debug_Libraries 0
41-# PROP Output_Dir "Release"
42-# PROP Intermediate_Dir "Release"
43-# PROP Ignore_Export_Lib 0
44-# PROP Target_Dir ""
45-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
46-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
47-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
48-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
49-# ADD BASE RSC /l 0x409 /d "NDEBUG"
50-# ADD RSC /l 0x409 /d "NDEBUG"
51-BSC32=bscmake.exe
52-# ADD BASE BSC32 /nologo
53-# ADD BSC32 /nologo
54-LINK32=link.exe
55-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
56-# ADD LINK32 ..\..\libpng-1.2.5\Release\libpng.lib ..\..\zlib-1.1.4\Release\zlib.lib ..\Release\pngdib.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib shell32.lib /nologo /subsystem:windows /machine:I386
57-
58-!ELSEIF "$(CFG)" == "smview - Win32 Debug"
59-
60-# PROP BASE Use_MFC 0
61-# PROP BASE Use_Debug_Libraries 1
62-# PROP BASE Output_Dir "Debug"
63-# PROP BASE Intermediate_Dir "Debug"
64-# PROP BASE Target_Dir ""
65-# PROP Use_MFC 0
66-# PROP Use_Debug_Libraries 1
67-# PROP Output_Dir "Debug"
68-# PROP Intermediate_Dir "Debug"
69-# PROP Ignore_Export_Lib 0
70-# PROP Target_Dir ""
71-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
72-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
73-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
74-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
75-# ADD BASE RSC /l 0x409 /d "_DEBUG"
76-# ADD RSC /l 0x409 /d "_DEBUG"
77-BSC32=bscmake.exe
78-# ADD BASE BSC32 /nologo
79-# ADD BSC32 /nologo
80-LINK32=link.exe
81-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
82-# ADD LINK32 ..\..\libpng-1.2.5\Debug\libpng.lib ..\..\zlib-1.1.4\Debug\zlib.lib ..\Debug\pngdib.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
83-
84-!ENDIF
85-
86-# Begin Target
87-
88-# Name "smview - Win32 Release"
89-# Name "smview - Win32 Debug"
90-# Begin Source File
91-
92-SOURCE=.\smview.c
93-# End Source File
94-# Begin Source File
95-
96-SOURCE=.\smview.ico
97-# End Source File
98-# Begin Source File
99-
100-SOURCE=.\smview.rc
101-# End Source File
102-# End Target
103-# End Project
diff -r d318a549c7e1 -r 01ac235d4a64 smview/smview.rc
--- a/smview/smview.rc Sat Jan 18 04:23:01 2014 +0000
+++ b/smview/smview.rc Sat Jan 18 04:24:47 2014 +0000
@@ -7,7 +7,8 @@
77 //
88 // Generated from the TEXTINCLUDE 2 resource.
99 //
10-#include "afxres.h"
10+//#include "afxres.h"
11+#include "winresrc.h"
1112
1213 /////////////////////////////////////////////////////////////////////////////
1314 #undef APSTUDIO_READONLY_SYMBOLS
@@ -127,8 +128,8 @@
127128 //
128129
129130 VS_VERSION_INFO VERSIONINFO
130- FILEVERSION 3,0,0,1
131- PRODUCTVERSION 3,0,0,1
131+ FILEVERSION 3,0,2,1
132+ PRODUCTVERSION 3,0,2,1
132133 FILEFLAGSMASK 0x3fL
133134 #ifdef _DEBUG
134135 FILEFLAGS 0x1L
@@ -146,14 +147,14 @@
146147 VALUE "Comments", "\0"
147148 VALUE "CompanyName", "Jason Summers\0"
148149 VALUE "FileDescription", "smview - a sample PNG image viewer\0"
149- VALUE "FileVersion", "3, 0, 0, 1\0"
150+ VALUE "FileVersion", "3, 0, 2, 1\0"
150151 VALUE "InternalName", "smview\0"
151152 VALUE "LegalCopyright", "-\0"
152153 VALUE "LegalTrademarks", "\0"
153154 VALUE "OriginalFilename", "smview.exe\0"
154155 VALUE "PrivateBuild", "\0"
155156 VALUE "ProductName", "smview\0"
156- VALUE "ProductVersion", "3, 0, 0, 1\0"
157+ VALUE "ProductVersion", "3, 0, 2, 1\0"
157158 VALUE "SpecialBuild", "\0"
158159 END
159160 END
diff -r d318a549c7e1 -r 01ac235d4a64 smview/smview.vcproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/smview/smview.vcproj Sat Jan 18 04:24:47 2014 +0000
@@ -0,0 +1,443 @@
1+<?xml version="1.0" encoding="Windows-1252"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="9.00"
5+ Name="smview"
6+ ProjectGUID="{56ADDE9B-629D-4C52-8BEA-181BFAAD4740}"
7+ RootNamespace="smview"
8+ TargetFrameworkVersion="0"
9+ >
10+ <Platforms>
11+ <Platform
12+ Name="Win32"
13+ />
14+ </Platforms>
15+ <ToolFiles>
16+ </ToolFiles>
17+ <Configurations>
18+ <Configuration
19+ Name="Release|Win32"
20+ OutputDirectory="$(ConfigurationName)"
21+ IntermediateDirectory="$(ConfigurationName)"
22+ ConfigurationType="1"
23+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
24+ UseOfMFC="0"
25+ ATLMinimizesCRunTimeLibraryUsage="false"
26+ CharacterSet="2"
27+ >
28+ <Tool
29+ Name="VCPreBuildEventTool"
30+ />
31+ <Tool
32+ Name="VCCustomBuildTool"
33+ />
34+ <Tool
35+ Name="VCXMLDataGeneratorTool"
36+ />
37+ <Tool
38+ Name="VCWebServiceProxyGeneratorTool"
39+ />
40+ <Tool
41+ Name="VCMIDLTool"
42+ PreprocessorDefinitions="NDEBUG"
43+ MkTypLibCompatible="true"
44+ SuppressStartupBanner="true"
45+ TargetEnvironment="1"
46+ TypeLibraryName=".\Release/smview.tlb"
47+ HeaderFileName=""
48+ />
49+ <Tool
50+ Name="VCCLCompilerTool"
51+ Optimization="2"
52+ AdditionalIncludeDirectories="..\"
53+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
54+ StringPooling="true"
55+ RuntimeLibrary="0"
56+ WarningLevel="3"
57+ SuppressStartupBanner="true"
58+ />
59+ <Tool
60+ Name="VCManagedResourceCompilerTool"
61+ />
62+ <Tool
63+ Name="VCResourceCompilerTool"
64+ PreprocessorDefinitions="NDEBUG"
65+ Culture="1033"
66+ />
67+ <Tool
68+ Name="VCPreLinkEventTool"
69+ />
70+ <Tool
71+ Name="VCLinkerTool"
72+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
73+ OutputFile="$(OutDir)/smview.exe"
74+ LinkIncremental="1"
75+ SuppressStartupBanner="true"
76+ SubSystem="2"
77+ />
78+ <Tool
79+ Name="VCALinkTool"
80+ />
81+ <Tool
82+ Name="VCManifestTool"
83+ />
84+ <Tool
85+ Name="VCXDCMakeTool"
86+ />
87+ <Tool
88+ Name="VCBscMakeTool"
89+ SuppressStartupBanner="true"
90+ />
91+ <Tool
92+ Name="VCFxCopTool"
93+ />
94+ <Tool
95+ Name="VCAppVerifierTool"
96+ />
97+ <Tool
98+ Name="VCPostBuildEventTool"
99+ />
100+ </Configuration>
101+ <Configuration
102+ Name="Debug|Win32"
103+ OutputDirectory="$(ConfigurationName)"
104+ IntermediateDirectory="$(ConfigurationName)"
105+ ConfigurationType="1"
106+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
107+ UseOfMFC="0"
108+ ATLMinimizesCRunTimeLibraryUsage="false"
109+ CharacterSet="2"
110+ >
111+ <Tool
112+ Name="VCPreBuildEventTool"
113+ />
114+ <Tool
115+ Name="VCCustomBuildTool"
116+ />
117+ <Tool
118+ Name="VCXMLDataGeneratorTool"
119+ />
120+ <Tool
121+ Name="VCWebServiceProxyGeneratorTool"
122+ />
123+ <Tool
124+ Name="VCMIDLTool"
125+ PreprocessorDefinitions="_DEBUG"
126+ MkTypLibCompatible="true"
127+ SuppressStartupBanner="true"
128+ TargetEnvironment="1"
129+ TypeLibraryName=".\Debug/smview.tlb"
130+ HeaderFileName=""
131+ />
132+ <Tool
133+ Name="VCCLCompilerTool"
134+ Optimization="0"
135+ AdditionalIncludeDirectories="..\"
136+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
137+ MinimalRebuild="true"
138+ RuntimeLibrary="1"
139+ BrowseInformation="1"
140+ WarningLevel="3"
141+ SuppressStartupBanner="true"
142+ DebugInformationFormat="4"
143+ />
144+ <Tool
145+ Name="VCManagedResourceCompilerTool"
146+ />
147+ <Tool
148+ Name="VCResourceCompilerTool"
149+ PreprocessorDefinitions="_DEBUG"
150+ Culture="1033"
151+ />
152+ <Tool
153+ Name="VCPreLinkEventTool"
154+ />
155+ <Tool
156+ Name="VCLinkerTool"
157+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
158+ OutputFile="$(OutDir)/smview.exe"
159+ LinkIncremental="2"
160+ SuppressStartupBanner="true"
161+ GenerateDebugInformation="true"
162+ SubSystem="2"
163+ />
164+ <Tool
165+ Name="VCALinkTool"
166+ />
167+ <Tool
168+ Name="VCManifestTool"
169+ />
170+ <Tool
171+ Name="VCXDCMakeTool"
172+ />
173+ <Tool
174+ Name="VCBscMakeTool"
175+ SuppressStartupBanner="true"
176+ />
177+ <Tool
178+ Name="VCFxCopTool"
179+ />
180+ <Tool
181+ Name="VCAppVerifierTool"
182+ />
183+ <Tool
184+ Name="VCPostBuildEventTool"
185+ />
186+ </Configuration>
187+ <Configuration
188+ Name="DebugU|Win32"
189+ OutputDirectory="$(ConfigurationName)"
190+ IntermediateDirectory="$(ConfigurationName)"
191+ ConfigurationType="1"
192+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
193+ UseOfMFC="0"
194+ ATLMinimizesCRunTimeLibraryUsage="false"
195+ CharacterSet="1"
196+ >
197+ <Tool
198+ Name="VCPreBuildEventTool"
199+ />
200+ <Tool
201+ Name="VCCustomBuildTool"
202+ />
203+ <Tool
204+ Name="VCXMLDataGeneratorTool"
205+ />
206+ <Tool
207+ Name="VCWebServiceProxyGeneratorTool"
208+ />
209+ <Tool
210+ Name="VCMIDLTool"
211+ PreprocessorDefinitions="_DEBUG"
212+ MkTypLibCompatible="true"
213+ SuppressStartupBanner="true"
214+ TargetEnvironment="1"
215+ TypeLibraryName=".\Debug/smview.tlb"
216+ HeaderFileName=""
217+ />
218+ <Tool
219+ Name="VCCLCompilerTool"
220+ Optimization="0"
221+ AdditionalIncludeDirectories="..\"
222+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
223+ MinimalRebuild="true"
224+ RuntimeLibrary="1"
225+ BrowseInformation="1"
226+ WarningLevel="3"
227+ SuppressStartupBanner="true"
228+ DebugInformationFormat="4"
229+ />
230+ <Tool
231+ Name="VCManagedResourceCompilerTool"
232+ />
233+ <Tool
234+ Name="VCResourceCompilerTool"
235+ PreprocessorDefinitions="_DEBUG"
236+ Culture="1033"
237+ />
238+ <Tool
239+ Name="VCPreLinkEventTool"
240+ />
241+ <Tool
242+ Name="VCLinkerTool"
243+ AdditionalDependencies="..\..\libpng-1.4.1\Debug\libpng.lib ..\..\zlib-1.2.3\Debug\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
244+ OutputFile="$(OutDir)/smview.exe"
245+ LinkIncremental="2"
246+ SuppressStartupBanner="true"
247+ GenerateDebugInformation="true"
248+ SubSystem="2"
249+ />
250+ <Tool
251+ Name="VCALinkTool"
252+ />
253+ <Tool
254+ Name="VCManifestTool"
255+ />
256+ <Tool
257+ Name="VCXDCMakeTool"
258+ />
259+ <Tool
260+ Name="VCBscMakeTool"
261+ SuppressStartupBanner="true"
262+ />
263+ <Tool
264+ Name="VCFxCopTool"
265+ />
266+ <Tool
267+ Name="VCAppVerifierTool"
268+ />
269+ <Tool
270+ Name="VCPostBuildEventTool"
271+ />
272+ </Configuration>
273+ <Configuration
274+ Name="ReleaseU|Win32"
275+ OutputDirectory="$(ConfigurationName)"
276+ IntermediateDirectory="$(ConfigurationName)"
277+ ConfigurationType="1"
278+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
279+ UseOfMFC="0"
280+ ATLMinimizesCRunTimeLibraryUsage="false"
281+ CharacterSet="1"
282+ >
283+ <Tool
284+ Name="VCPreBuildEventTool"
285+ />
286+ <Tool
287+ Name="VCCustomBuildTool"
288+ />
289+ <Tool
290+ Name="VCXMLDataGeneratorTool"
291+ />
292+ <Tool
293+ Name="VCWebServiceProxyGeneratorTool"
294+ />
295+ <Tool
296+ Name="VCMIDLTool"
297+ PreprocessorDefinitions="NDEBUG"
298+ MkTypLibCompatible="true"
299+ SuppressStartupBanner="true"
300+ TargetEnvironment="1"
301+ TypeLibraryName=".\Release/smview.tlb"
302+ HeaderFileName=""
303+ />
304+ <Tool
305+ Name="VCCLCompilerTool"
306+ Optimization="2"
307+ AdditionalIncludeDirectories="..\"
308+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
309+ StringPooling="true"
310+ RuntimeLibrary="0"
311+ WarningLevel="3"
312+ SuppressStartupBanner="true"
313+ />
314+ <Tool
315+ Name="VCManagedResourceCompilerTool"
316+ />
317+ <Tool
318+ Name="VCResourceCompilerTool"
319+ PreprocessorDefinitions="NDEBUG"
320+ Culture="1033"
321+ />
322+ <Tool
323+ Name="VCPreLinkEventTool"
324+ />
325+ <Tool
326+ Name="VCLinkerTool"
327+ AdditionalDependencies="..\..\libpng-1.4.1\Release\libpng.lib ..\..\zlib-1.2.3\Release\zlib.lib ..\$(ConfigurationName)\pngdib.lib"
328+ OutputFile="$(OutDir)/smview.exe"
329+ LinkIncremental="1"
330+ SuppressStartupBanner="true"
331+ SubSystem="2"
332+ />
333+ <Tool
334+ Name="VCALinkTool"
335+ />
336+ <Tool
337+ Name="VCManifestTool"
338+ />
339+ <Tool
340+ Name="VCXDCMakeTool"
341+ />
342+ <Tool
343+ Name="VCBscMakeTool"
344+ SuppressStartupBanner="true"
345+ />
346+ <Tool
347+ Name="VCFxCopTool"
348+ />
349+ <Tool
350+ Name="VCAppVerifierTool"
351+ />
352+ <Tool
353+ Name="VCPostBuildEventTool"
354+ />
355+ </Configuration>
356+ </Configurations>
357+ <References>
358+ </References>
359+ <Files>
360+ <File
361+ RelativePath="smview.c"
362+ >
363+ <FileConfiguration
364+ Name="Release|Win32"
365+ >
366+ <Tool
367+ Name="VCCLCompilerTool"
368+ AdditionalIncludeDirectories=""
369+ PreprocessorDefinitions=""
370+ />
371+ </FileConfiguration>
372+ <FileConfiguration
373+ Name="Debug|Win32"
374+ >
375+ <Tool
376+ Name="VCCLCompilerTool"
377+ AdditionalIncludeDirectories=""
378+ PreprocessorDefinitions=""
379+ />
380+ </FileConfiguration>
381+ <FileConfiguration
382+ Name="DebugU|Win32"
383+ >
384+ <Tool
385+ Name="VCCLCompilerTool"
386+ AdditionalIncludeDirectories=""
387+ PreprocessorDefinitions=""
388+ />
389+ </FileConfiguration>
390+ <FileConfiguration
391+ Name="ReleaseU|Win32"
392+ >
393+ <Tool
394+ Name="VCCLCompilerTool"
395+ AdditionalIncludeDirectories=""
396+ PreprocessorDefinitions=""
397+ />
398+ </FileConfiguration>
399+ </File>
400+ <File
401+ RelativePath="smview.ico"
402+ >
403+ </File>
404+ <File
405+ RelativePath="smview.rc"
406+ >
407+ <FileConfiguration
408+ Name="Release|Win32"
409+ >
410+ <Tool
411+ Name="VCResourceCompilerTool"
412+ PreprocessorDefinitions=""
413+ />
414+ </FileConfiguration>
415+ <FileConfiguration
416+ Name="Debug|Win32"
417+ >
418+ <Tool
419+ Name="VCResourceCompilerTool"
420+ PreprocessorDefinitions=""
421+ />
422+ </FileConfiguration>
423+ <FileConfiguration
424+ Name="DebugU|Win32"
425+ >
426+ <Tool
427+ Name="VCResourceCompilerTool"
428+ PreprocessorDefinitions=""
429+ />
430+ </FileConfiguration>
431+ <FileConfiguration
432+ Name="ReleaseU|Win32"
433+ >
434+ <Tool
435+ Name="VCResourceCompilerTool"
436+ PreprocessorDefinitions=""
437+ />
438+ </FileConfiguration>
439+ </File>
440+ </Files>
441+ <Globals>
442+ </Globals>
443+</VisualStudioProject>
Afficher sur ancien navigateur de dépôt.