Skip to content

Commit

Permalink
add VC++ 2008 solution; fix binary file open mode on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Jul 2, 2012
1 parent d2b0bf4 commit 1e48ef7
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
0.28: (not yet released)
* Update to the latest Leptonica (1.68)
* pdf.py now correctly retains DPI from input images (thanks to RubyPDF)
* autotools support
* autotools support, VC++ 2008 solution
* fix binary file open mode on Windows

0.27:
* Update to the latest Leptonica (1.58)
Expand Down
15 changes: 15 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ If you're running a Unix-like OS, such as Linux, BSD, Mac OS X or msys
./configure
make
make install (or sudo make install)


VC++ 2008 Notes
===============

Download leptonica-1.68-win32-lib-include-dirs.zip from
http://leptonica.com/download.html and unpack it so 'include', 'lib' and
'jbig2enc' directories are at the same directory (or adjust include path
in VC++ project).

Download stdint.h for Microsoft Visual Studio (part of package
msinttypes-r26.zip from http://code.google.com/p/msinttypes/downloads/list)
and place it to 'include' directory.

Them open vs2008/jbig2enc.sln in Visual C++ 2008 and build solution.
2 changes: 1 addition & 1 deletion pdf.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main(symboltable='symboltable', pagefiles=glob.glob('page-*')):
pagefiles.sort()
for p in pagefiles:
try:
contents = file(p).read()
contents = file(p, mode='rb').read()
except IOError:
sys.stderr.write("error reading page file %s\n"% p)
continue
Expand Down
15 changes: 13 additions & 2 deletions src/jbig2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#ifdef _MSC_VER
#include <io.h>
#else
#include <unistd.h>
#endif

#include <leptonica/allheaders.h>

Expand Down Expand Up @@ -205,6 +209,12 @@ main(int argc, char **argv) {
const char *img_ext = "png";
bool segment = false;
int i;

#ifdef WIN32
int result = _setmode(_fileno(stdout), _O_BINARY);
if (result == -1)
fprintf(stderr, "Cannot set mode to binary for stdout\n");
#endif

for (i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-h") == 0 ||
Expand Down Expand Up @@ -343,8 +353,9 @@ main(int argc, char **argv) {
if (subimage==numsubimages) {
subimage = numsubimages = 0;
FILE *fp;
if ((fp=fopen(argv[i], "r"))==NULL) {
fprintf(stderr, "Unable to open \"%s\"", argv[i]);
if (verbose) fprintf(stderr, "Processing \"%s\"...\n", argv[i]);
if ((fp=fopen(argv[i], "r"))==NULL) {
fprintf(stderr, "Unable to open \"%s\"\n", argv[i]);
return 1;
}
l_int32 filetype;
Expand Down
203 changes: 203 additions & 0 deletions vs2008/jbig2/jbig2.vcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="jbig2"
ProjectGUID="{3898E38A-63BE-4D73-828C-8AD70AF8B321}"
RootNamespace="jbig2"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="setargv.obj"
AdditionalDependencies="ws2_32.lib zlib125-static-mtdll-debug.lib libpng143-static-mtdll-debug.lib libjpeg8c-static-mtdll-debug.lib giflib416-static-mtdll-debug.lib libtiff394-static-mtdll-debug.lib liblept168-static-mtdll-debug.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
EnableManagedIncrementalBuild="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/wd4996"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="setargv.obj"
AdditionalDependencies="ws2_32.lib zlib125-static-mtdll.lib libpng143-static-mtdll.lib libjpeg8c-static-mtdll.lib giflib416-static-mtdll.lib libtiff394-static-mtdll.lib liblept168-static-mtdll.lib"
LinkIncremental="0"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\src\jbig2.cc"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
29 changes: 29 additions & 0 deletions vs2008/jbig2enc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jbig2", "jbig2\jbig2.vcproj", "{3898E38A-63BE-4D73-828C-8AD70AF8B321}"
ProjectSection(ProjectDependencies) = postProject
{6091B063-4892-490F-8538-91475A5DF370} = {6091B063-4892-490F-8538-91475A5DF370}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjbig2enc", "libjbig2enc\libjbig2enc.vcproj", "{6091B063-4892-490F-8538-91475A5DF370}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3898E38A-63BE-4D73-828C-8AD70AF8B321}.Debug|Win32.ActiveCfg = Debug|Win32
{3898E38A-63BE-4D73-828C-8AD70AF8B321}.Debug|Win32.Build.0 = Debug|Win32
{3898E38A-63BE-4D73-828C-8AD70AF8B321}.Release|Win32.ActiveCfg = Release|Win32
{3898E38A-63BE-4D73-828C-8AD70AF8B321}.Release|Win32.Build.0 = Release|Win32
{6091B063-4892-490F-8538-91475A5DF370}.Debug|Win32.ActiveCfg = Debug|Win32
{6091B063-4892-490F-8538-91475A5DF370}.Debug|Win32.Build.0 = Debug|Win32
{6091B063-4892-490F-8538-91475A5DF370}.Release|Win32.ActiveCfg = Release|Win32
{6091B063-4892-490F-8538-91475A5DF370}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading

0 comments on commit 1e48ef7

Please sign in to comment.