This commit is contained in:
2012-09-02 15:24:38 +02:00
commit 5b667b5781
250 changed files with 70477 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2003.vcproj", "{D1ABE87A-65A2-4AA2-9C94-73B9B4898C3B}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{D1ABE87A-65A2-4AA2-9C94-73B9B4898C3B}.Debug.ActiveCfg = Debug|Win32
{D1ABE87A-65A2-4AA2-9C94-73B9B4898C3B}.Debug.Build.0 = Debug|Win32
{D1ABE87A-65A2-4AA2-9C94-73B9B4898C3B}.Release.ActiveCfg = Release|Win32
{D1ABE87A-65A2-4AA2-9C94-73B9B4898C3B}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="fipTest"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/fipTest.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImaged.lib FreeImagePlusd.lib"
OutputFile=".\Debug/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/fipTest.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/fipTest.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/fipTest.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImage.lib FreeImagePlus.lib"
OutputFile=".\Release/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/fipTest.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/fipTest.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="fipTest.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="fipTest.h">
</File>
<File
RelativePath="fipTestMemIO.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="fipTestMPage.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath=".\fipTestMPageMemory.cpp">
</File>
<File
RelativePath=".\fipTestMPageStream.cpp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2005.vcproj", "{39B399CB-50D7-43CF-9967-CBA4309C7034}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{39B399CB-50D7-43CF-9967-CBA4309C7034}.Debug|Win32.ActiveCfg = Debug|Win32
{39B399CB-50D7-43CF-9967-CBA4309C7034}.Debug|Win32.Build.0 = Debug|Win32
{39B399CB-50D7-43CF-9967-CBA4309C7034}.Release|Win32.ActiveCfg = Release|Win32
{39B399CB-50D7-43CF-9967-CBA4309C7034}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,282 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="fipTest"
ProjectGUID="{39B399CB-50D7-43CF-9967-CBA4309C7034}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/fipTest.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Debug/fipTest.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImaged.lib FreeImagePlusd.lib"
OutputFile=".\Debug/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/fipTest.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/fipTest.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/fipTest.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImage.lib FreeImagePlus.lib"
OutputFile=".\Release/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/fipTest.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="fipTest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="fipTest.h"
>
</File>
<File
RelativePath="fipTestMemIO.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="fipTestMPage.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\fipTestMPageMemory.cpp"
>
</File>
<File
RelativePath=".\fipTestMPageStream.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fipTest", "fipTest.2008.vcproj", "{66DCA866-A381-42D5-97FB-9792066C0F20}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.ActiveCfg = Debug|Win32
{66DCA866-A381-42D5-97FB-9792066C0F20}.Debug|Win32.Build.0 = Debug|Win32
{66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.ActiveCfg = Release|Win32
{66DCA866-A381-42D5-97FB-9792066C0F20}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,281 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="fipTest"
ProjectGUID="{66DCA866-A381-42D5-97FB-9792066C0F20}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/fipTest.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Debug/fipTest.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImaged.lib FreeImagePlusd.lib"
OutputFile=".\Debug/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/fipTest.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
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=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/fipTest.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/fipTest.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="FreeImage.lib FreeImagePlus.lib"
OutputFile=".\Release/fipTest.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/fipTest.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<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>
<File
RelativePath="fipTest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="fipTest.h"
>
</File>
<File
RelativePath="fipTestMemIO.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="fipTestMPage.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\fipTestMPageMemory.cpp"
>
</File>
<File
RelativePath=".\fipTestMPageStream.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,76 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "fipTest.h"
using namespace std;
// ----------------------------------------------------------
/**
FreeImage error handler
@param fif Format / Plugin responsible for the error
@param message Error message
*/
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
cout << "\n*** ";
if(fif != FIF_UNKNOWN) {
cout << FreeImage_GetFormatFromFIF(fif) << " Format\n";
}
cout << message;
cout << " ***\n";
}
// ----------------------------------------------------------
int main(int argc, char *argv[]) {
char *lpszTestFile = "test.jpg";
char *lpszMultiPage = "test.tif";
#if defined(FREEIMAGE_LIB) || !defined(WIN32)
FreeImage_Initialise();
#endif
// initialize our own FreeImage error handler
FreeImage_SetOutputMessage(FreeImageErrorHandler);
// test memory IO
testMemIO(lpszTestFile);
// test multipage IO
testMultiPage(lpszMultiPage);
// test multipage memory IO
testMultiPageMemory(lpszMultiPage);
// test multipage stream IO
testStreamMultiPage(lpszMultiPage);
#if defined(FREEIMAGE_LIB) || !defined(WIN32)
FreeImage_DeInitialise();
#endif
return 0;
}

View File

@@ -0,0 +1,79 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#ifndef TEST_FREEIMAGEPLUS_API_H
#define TEST_FREEIMAGEPLUS_API_H
#include "../FreeImagePlus.h"
#include <stdlib.h>
#include <assert.h>
#include <sys/stat.h>
#include <iostream>
// --------------------------------------------------------------------------
// Memory IO test scripts
/// Test saving to a memory stream
void testSaveMemIO(const char *lpszPathName);
/// Test loading from a buffer attached to a memory stream
void testLoadMemIO(const char *lpszPathName);
/// Test extracting a memory buffer from a memory stream
void testAcquireMemIO(const char *lpszPathName);
/// Test Loading / Saving from / to a memory stream using fipImage
void testImageMemIO(const char *lpszPathName);
/// Test the above functions
void testMemIO(const char *lpszPathName);
// --------------------------------------------------------------------------
// Multipage test scripts
/// Test multipage loading & saving
BOOL testCloneMultiPage(const char *input, const char *output, int output_flag);
/// Test the above functions
void testMultiPage(const char *lpszMultiPage);
// --------------------------------------------------------------------------
// Multipage memory IO test scripts
/// test FreeImage_LoadMultiBitmapFromMemory
BOOL testLoadMultiBitmapFromMemory(const char *lpszPathName);
/// test FreeImage_SaveMultiBitmapToMemory
BOOL testSaveMultiBitmapToMemory(const char *input, const char *output, int output_flag);
/// test FreeImage_LoadMultiBitmapFromMemory & FreeImage_SaveMultiBitmapToMemory
BOOL testMemoryStreamMultiPageOpenSave(const char *lpszPathName, char *output, int input_flag, int output_flag);
/// Test the above functions
void testMultiPageMemory(const char *lpszPathName);
// --------------------------------------------------------------------------
// Multipage IO test scripts
/// test multipage stream (opening)
BOOL testStreamMultiPageOpen(const char *input, int flags);
/// test multipage stream (save as)
BOOL testStreamMultiPageSave(const char *input, const char *output, int input_flag, int output_flag);
/// test multipage stream (open, modify, save as)
BOOL testStreamMultiPageOpenSave(const char *input, const char *output, int input_flag, int output_flag);
/// Test the above functions
void testStreamMultiPage(const char *lpszPathName);
#endif // TEST_FREEIMAGEPLUS_API_H

View File

@@ -0,0 +1,82 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "fipTest.h"
using namespace std;
// --------------------------------------------------------------------------
// Multipage test scripts
BOOL testCloneMultiPage(const char *input, const char *output, int output_flag) {
BOOL bMemoryCache = TRUE;
fipMultiPage src(bMemoryCache);
fipMultiPage dst(bMemoryCache);
// You MUST declare this before using it.
// We will use the assignement operator, i.e. operator=()
fipImage image;
// Open src file (read-only, use memory cache)
src.open(input, FALSE, TRUE);
if(src.isValid()) {
// Open dst file (creation, use memory cache)
dst.open(output, TRUE, FALSE);
// Get src page count
int count = src.getPageCount();
// Clone src to dst
for(int page = 0; page < count; page++) {
// Load the bitmap at position 'page'
image = src.lockPage(page);
if(image.isValid()) {
// add a new bitmap to dst
dst.appendPage(image);
// Unload the bitmap (do not apply any change to src)
src.unlockPage(image, FALSE);
}
}
// Close src
src.close(0);
// Save and close dst
dst.close(output_flag);
return TRUE;
}
return FALSE;
}
// ----------------------------------------------------------
void testMultiPage(const char *lpszMultiPage) {
cout << "testMultiPage ...\n";
testCloneMultiPage(lpszMultiPage, "clone.tif", 0);
}

View File

@@ -0,0 +1,276 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "fipTest.h"
using namespace std;
// --------------------------------------------------------------------------
static BOOL
loadBuffer(const char *lpszPathName, BYTE **buffer, DWORD *length) {
struct stat file_info;
int result;
// get data associated with lpszPathName
result = stat(lpszPathName, &file_info);
if(result == 0) {
// allocate a memory buffer and load temporary data
*buffer = (BYTE*)malloc(file_info.st_size * sizeof(BYTE));
if(*buffer) {
FILE *stream = fopen(lpszPathName, "rb");
if(stream) {
*length = (DWORD)fread(*buffer, sizeof(BYTE), file_info.st_size, stream);
fclose(stream);
return TRUE;
}
}
}
return FALSE;
}
static BOOL
extractPagesFromMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO) {
BOOL bMemoryCache = TRUE;
char filename[256];
fipImage image;
// open the multipage bitmap stream as read-only
fipMultiPage src(bMemoryCache);
src.open(memIO);
if(src.isValid()) {
// get the page count
int count = src.getPageCount();
// extract all pages
for(int page = 0; page < count; page++) {
// load the bitmap at position 'page'
image = src.lockPage(page);
if(image.isValid()) {
// save the page
sprintf(filename, "page%d.%s", page, FreeImage_GetFormatFromFIF(fif));
image.save(filename, 0);
// Unload the bitmap (do not apply any change to src)
src.unlockPage(image, FALSE);
} else {
// an error occured: free the multipage bitmap handle (fipMultiPage destructor) and return
src.close(0);
return FALSE;
}
}
}
// make sure to close the multipage bitmap handle on exit (fipMultiPage destructor or direct call to src.close(0))
return src.close(0);
}
BOOL testLoadMultiBitmapFromMemory(const char *lpszPathName) {
BOOL bSuccess = FALSE;
BYTE *buffer = NULL;
DWORD buffer_size = 0;
// load source stream as a buffer, i.e.
// allocate a memory buffer and load temporary data
bSuccess = loadBuffer(lpszPathName, &buffer, &buffer_size);
assert(bSuccess);
if(bSuccess) {
// attach the binary data to a memory stream
fipMemoryIO memIO(buffer, buffer_size);
// get the file type
FREE_IMAGE_FORMAT fif = memIO.getFileType();
// extract pages
bSuccess = extractPagesFromMemory(fif, memIO);
assert(bSuccess);
// close the memory stream (memIO destructor)
}
// user is responsible for freeing the data
free(buffer);
return bSuccess;
}
// --------------------------------------------------------------------------
BOOL testSaveMultiBitmapToMemory(const char *input, const char *output, int output_flag) {
BOOL bSuccess;
BOOL bCreateNew = FALSE;
BOOL bReadOnly = TRUE;
BOOL bMemoryCache = TRUE;
// Open src file (read-only, use memory cache)
fipMultiPage src(bMemoryCache);
src.open(input, bCreateNew, bReadOnly, 0);
if(src.isValid()) {
// open and allocate a memory stream
fipMemoryIO memIO;
// save the file to memory
FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output);
bSuccess = src.saveToMemory(fif, memIO, output_flag);
assert(bSuccess);
// src is no longer needed: close and free src file
src.close(0);
// get the buffer from the memory stream
BYTE *mem_buffer = NULL;
DWORD size_in_bytes = 0;
bSuccess = memIO.acquire(&mem_buffer, &size_in_bytes);
assert(bSuccess);
// save the buffer in a file stream
FILE *stream = fopen(output, "wb");
if(stream) {
fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream);
fclose(stream);
}
// close and free the memory stream (memIO destructor)
return TRUE;
}
return FALSE;
}
BOOL testMemoryStreamMultiPageOpenSave(const char *lpszPathName, char *output, int input_flag, int output_flag) {
BOOL bSuccess = FALSE;
BYTE *buffer = NULL;
DWORD buffer_size = 0;
// load source stream as a buffer, i.e.
// allocate a memory buffer and load temporary data
bSuccess = loadBuffer(lpszPathName, &buffer, &buffer_size);
assert(bSuccess);
// attach the binary data to a memory stream
fipMemoryIO src_stream(buffer, buffer_size);
assert(src_stream.isValid());
// open the multipage bitmap stream
fipMultiPage src;
src.open(src_stream, input_flag);
// apply some modifications (everything being stored to the cache) ...
if(src.isValid()) {
fipImage image;
// get the page count
int count = src.getPageCount();
assert(count > 2);
// Load the bitmap at position '2'
image = src.lockPage(2);
if(image.isValid()) {
image.invert();
// Unload the bitmap (apply change to src, modifications are stored to the cache)
src.unlockPage(image, TRUE);
}
// delete page 0 (modifications are stored to the cache)
src.deletePage(0);
// insert a new page at position '0' (modifications are stored to the cache)
image.load("test.jpg");
src.insertPage(0, image);
}
// save the modification into the output stream ...
if(src.isValid()) {
// open and allocate a memory stream
fipMemoryIO dst_stream;
assert(dst_stream.isValid());
// save the file to memory
FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output);
src.saveToMemory(fif, dst_stream, output_flag);
// src is no longer needed
// close and free the memory stream
src_stream.close();
// close and free src file (nothing is done, the cache is cleared)
src.close(0);
// at this point, the input buffer is no longer needed
// !!! user is responsible for freeing the initial source buffer !!!
free(buffer); buffer = NULL;
// get the dst buffer from the memory stream
BYTE *dst_buffer = NULL;
DWORD size_in_bytes = 0;
dst_stream.acquire(&dst_buffer, &size_in_bytes);
// save the buffer in a file stream
FILE *stream = fopen(output, "wb");
if(stream) {
fwrite(dst_buffer, sizeof(BYTE), size_in_bytes, stream);
fclose(stream);
}
// close and free the memory stream (destructor is called)
return TRUE;
}
if(buffer) {
free(buffer);
}
return FALSE;
}
// --------------------------------------------------------------------------
void testMultiPageMemory(const char *lpszPathName) {
BOOL bSuccess;
cout << "testMultiPageMemory ...\n";
// test FreeImage_LoadMultiBitmapFromMemory
bSuccess = testLoadMultiBitmapFromMemory(lpszPathName);
assert(bSuccess);
// test FreeImage_SaveMultiBitmapToMemory
bSuccess = testSaveMultiBitmapToMemory(lpszPathName, "mpage-mstream.tif", 0);
assert(bSuccess);
// test FreeImage_LoadMultiBitmapFromMemory & FreeImage_SaveMultiBitmapToMemory
bSuccess = testMemoryStreamMultiPageOpenSave(lpszPathName, "mpage-mstream-redirect.tif", 0, 0);
assert(bSuccess);
}

View File

@@ -0,0 +1,222 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "fipTest.h"
using namespace std;
// --------------------------------------------------------------------------
static unsigned DLL_CALLCONV
myReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
return fread(buffer, size, count, (FILE *)handle);
}
static unsigned DLL_CALLCONV
myWriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
return fwrite(buffer, size, count, (FILE *)handle);
}
static int DLL_CALLCONV
mySeekProc(fi_handle handle, long offset, int origin) {
return fseek((FILE *)handle, offset, origin);
}
static long DLL_CALLCONV
myTellProc(fi_handle handle) {
return ftell((FILE *)handle);
}
BOOL testStreamMultiPageOpen(const char *input, int flags) {
// initialize your own IO functions
FreeImageIO io;
io.read_proc = myReadProc;
io.write_proc = myWriteProc;
io.seek_proc = mySeekProc;
io.tell_proc = myTellProc;
BOOL bSuccess = FALSE;
// Open src stream in read-only mode
FILE *file = fopen(input, "r+b");
if (file != NULL) {
fipMultiPage src;
// Open the multi-page file
src.open(&io, (fi_handle)file, flags);
if(src.isValid()) {
// get the page count
int count = src.getPageCount();
assert(count > 1);
// delete page 0 (modifications are stored to the cache)
src.deletePage(0);
// Close src file (nothing is done, the cache is cleared)
bSuccess = src.close(0);
assert(bSuccess);
}
// Close the src stream
fclose(file);
return bSuccess;
}
return bSuccess;
}
BOOL testStreamMultiPageSave(const char *input, const char *output, int input_flag, int output_flag) {
// initialize your own IO functions
FreeImageIO io;
io.read_proc = myReadProc;
io.write_proc = myWriteProc;
io.seek_proc = mySeekProc;
io.tell_proc = myTellProc;
BOOL bCreateNew = FALSE;
BOOL bReadOnly = TRUE;
BOOL bMemoryCache = TRUE;
// Open src file (read-only, use memory cache)
fipMultiPage src(bMemoryCache);
src.open(input, bCreateNew, bReadOnly, input_flag);
if(src.isValid()) {
// Open dst stream in read/write mode
FILE *file = fopen(output, "w+b");
if (file != NULL) {
// Save the multi-page file to the stream
FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output);
BOOL bSuccess = src.saveToHandle(fif, &io, (fi_handle)file, output_flag);
assert(bSuccess);
// Close the dst stream
fclose(file);
// Close src file (or let the destructor close it)
return src.close(0);
return TRUE;
}
// Close src file (or let the destructor close it)
src.close(0);
}
return FALSE;
}
BOOL testStreamMultiPageOpenSave(const char *input, const char *output, int input_flag, int output_flag) {
// initialize your own IO functions
FreeImageIO io;
io.read_proc = myReadProc;
io.write_proc = myWriteProc;
io.seek_proc = mySeekProc;
io.tell_proc = myTellProc;
BOOL bSuccess = FALSE;
// Open src stream in read-only mode
FILE *src_file = fopen(input, "r+b");
assert(src_file);
if (src_file != NULL) {
fipMultiPage src;
// Open the multi-page file
src.open(&io, (fi_handle)src_file, input_flag);
if(src.isValid()) {
fipImage image;
// get the page count
int count = src.getPageCount();
assert(count > 2);
// Load the bitmap at position '2'
image = src.lockPage(2);
if(image.isValid()) {
image.invert();
// Unload the bitmap (apply change to src, modifications are stored to the cache)
src.unlockPage(image, TRUE);
}
// delete page 0 (modifications are stored to the cache)
src.deletePage(0);
// insert a new page at position '0' (modifications are stored to the cache)
image.load("test.jpg");
src.insertPage(0, image);
// Open dst stream in read/write mode
FILE *dst_file = fopen(output, "w+b");
assert(dst_file);
if (dst_file != NULL) {
// Save the multi-page file to the stream (modifications are applied)
FREE_IMAGE_FORMAT fif = fipImage::identifyFIF(output);
BOOL bSuccess = src.saveToHandle(fif, &io, (fi_handle)dst_file, output_flag);
assert(bSuccess);
// Close the dst stream
fclose(dst_file);
}
// Close src file (nothing is done, the cache is cleared)
bSuccess = src.close(0);
assert(bSuccess);
}
// Close the src stream
fclose(src_file);
return bSuccess;
}
return FALSE;
}
// --------------------------------------------------------------------------
void testStreamMultiPage(const char *lpszPathName) {
BOOL bSuccess;
cout << "testStreamMultiPage ...\n";
// test multipage stream (opening)
bSuccess = testStreamMultiPageOpen(lpszPathName, 0);
assert(bSuccess);
// test multipage stream (save as)
bSuccess = testStreamMultiPageSave(lpszPathName, "clone-stream.tif", 0, 0);
assert(bSuccess);
// test multipage stream (open, modify, save as)
bSuccess = testStreamMultiPageOpenSave(lpszPathName, "redirect-stream.tif", 0, 0);
assert(bSuccess);
}

View File

@@ -0,0 +1,171 @@
// ==========================================================
// FreeImagePlus Test Script
//
// Design and implementation by
// - Herv<72> Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "fipTest.h"
using namespace std;
// --------------------------------------------------------------------------
// Memory IO test scripts
/**
Test saving to a memory stream
*/
void testSaveMemIO(const char *lpszPathName) {
// load a regular file
FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName);
FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0);
// open a memory handle
fipMemoryIO memIO;
// save the file to memory
memIO.save(fif, dib, 0);
// at this point, memIO contains the entire PNG data in memory.
// the amount of space used by the memory is equal to file_size
long file_size = memIO.tell();
assert(file_size != 0);
// its easy load an image from memory as well
// seek to the start of the memory stream
memIO.seek(0L, SEEK_SET);
// get the file type
FREE_IMAGE_FORMAT mem_fif = memIO.getFileType();
// load an image from the memory handle
FIBITMAP *check = memIO.load(mem_fif, 0);
// save as a regular file
FreeImage_Save(FIF_PNG, check, "dump.png", PNG_DEFAULT);
FreeImage_Unload(check);
FreeImage_Unload(dib);
// The memIO object will be destroyed automatically
}
/**
Test loading from a buffer attached to a memory stream
*/
void testLoadMemIO(const char *lpszPathName) {
struct stat buf;
int result;
// get data associated with lpszPathName
result = stat(lpszPathName, &buf);
if(result == 0) {
// allocate a memory buffer and load temporary data
BYTE *mem_buffer = (BYTE*)malloc(buf.st_size * sizeof(BYTE));
if(mem_buffer) {
FILE *stream = fopen(lpszPathName, "rb");
if(stream) {
fread(mem_buffer, sizeof(BYTE), buf.st_size, stream);
fclose(stream);
// attach the binary data to a memory stream
fipMemoryIO memIO(mem_buffer, buf.st_size);
// get the file type
FREE_IMAGE_FORMAT fif = memIO.getFileType();
// load an image from the memory stream
FIBITMAP *check = memIO.load(fif, PNG_DEFAULT);
// save as a regular file
FreeImage_Save(FIF_PNG, check, "blob.png", PNG_DEFAULT);
// close the stream (memIO is destroyed)
}
// user is responsible for freeing the data
free(mem_buffer);
}
}
}
/**
Test extracting a memory buffer from a memory stream
*/
void testAcquireMemIO(const char *lpszPathName) {
// load a regular file
FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName);
FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0);
// open and allocate a memory stream
fipMemoryIO memIO;
// save the file to memory
memIO.save(FIF_PNG, dib, PNG_DEFAULT);
// get the buffer from the memory stream
BYTE *mem_buffer = NULL;
DWORD size_in_bytes = 0;
memIO.acquire(&mem_buffer, &size_in_bytes);
// save the buffer in a file stream
FILE *stream = fopen("buffer.png", "wb");
if(stream) {
fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream);
fclose(stream);
}
// close and free the memory stream (memIO is destroyed)
}
/**
Test Loading / Saving from / to a memory stream using fipImage
*/
void testImageMemIO(const char *lpszPathName) {
BOOL bSuccess = FALSE;
fipMemoryIO memIO;
fipImage image;
// load a regular file
bSuccess = image.load(lpszPathName);
if(bSuccess) {
// save the file to a memory stream
bSuccess = image.saveToMemory(FIF_PNG, memIO, PNG_DEFAULT);
assert(bSuccess);
// load the file from the memory stream
memIO.seek(0L, SEEK_SET);
bSuccess = image.loadFromMemory(memIO, 0);
assert(bSuccess);
}
}
void testMemIO(const char *lpszPathName) {
cout << "testMemIO ...\n";
testSaveMemIO(lpszPathName);
testLoadMemIO(lpszPathName);
testAcquireMemIO(lpszPathName);
testImageMemIO(lpszPathName);
}