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,58 @@
#include "stdafx.h"
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("")];
[assembly:AssemblyCopyrightAttribute("")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project directory.
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly:AssemblyDelaySignAttribute(false)];
[assembly:AssemblyKeyFileAttribute("")];
[assembly:AssemblyKeyNameAttribute("")];

View File

@@ -0,0 +1,69 @@
// ==========================================================
// FreeImageIO.Net
//
// Design and implementation by
// - Marcos Pernambuco Motta (marcos.pernambuco@gmail.com)
//
// 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 "stdafx.h"
#include "FreeImageIO.Net.h"
extern "C" static unsigned __stdcall ReadProc (void *buffer, unsigned size, unsigned count, fi_handle handle)
{
int total_read = 0;
struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle;
gcroot<unsigned char __gc []> mbuffer = new unsigned char __gc[size];
try
{
total_read = puh->_stream->Read(mbuffer,0,size);
Marshal::Copy(mbuffer,0,buffer,total_read);
} __finally {
mbuffer=NULL;
}
return (unsigned)total_read;
}
extern "C" static unsigned __stdcall WriteProc (void *buffer, unsigned size, unsigned count, fi_handle handle)
{
struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle;
gcroot<unsigned char __gc []> mbuffer = new unsigned char __gc[size*count];
try
{
unsigned char __pin* pbuffer = &mbuffer[0];
memcpy(pbuffer,buffer,size*count);
puh->_stream->Write(mbuffer,0,size);
} __finally {
mbuffer=NULL;
}
return count;
}
extern "C" static int __stdcall SeekProc (fi_handle handle, long offset, int origin)
{
struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle;
return (int)puh->_stream->Seek(offset,(SeekOrigin) origin);
}
extern "C" static long __stdcall TellProc(fi_handle handle)
{
struct UNMANAGED_HANDLER* puh = (struct UNMANAGED_HANDLER*)handle;
return (long)puh->_stream->Position;
}

View File

@@ -0,0 +1,83 @@
// ==========================================================
// FreeImageIO.Net
//
// Design and implementation by
// - Marcos Pernambuco Motta (marcos.pernambuco@gmail.com)
//
// 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!
// ==========================================================
#pragma once
#include <vcclr.h>
#include "FreeImage.h"
using namespace System;
using namespace System::IO;
using namespace System::Runtime::InteropServices;
extern "C" {
// forward decls
unsigned __stdcall ReadProc (void *buffer, unsigned size, unsigned count, fi_handle handle);
unsigned __stdcall WriteProc (void *buffer, unsigned size, unsigned count, fi_handle handle);
int __stdcall SeekProc (fi_handle handle, long offset, int origin);
long __stdcall TellProc(fi_handle handle);
#pragma pack(push, 1)
__nogc struct UNMANAGED_HANDLER {
UNMANAGED_HANDLER() {
read_proc = &ReadProc;
write_proc = WriteProc;
seek_proc = SeekProc;
tell_proc = TellProc;
}
FI_ReadProc read_proc; // pointer to the function used to read data
FI_WriteProc write_proc; // pointer to the function used to write data
FI_SeekProc seek_proc; // pointer to the function used to seek
FI_TellProc tell_proc; // pointer to the function used to aquire the current position
gcroot<System::IO::Stream*> _stream;
};
#pragma pack(pop)
}
#define FREEIMAGE_DLL "freeimaged.dll"
namespace FreeImageIODotNet
{
__gc public class FreeImageStream
{
private:
struct UNMANAGED_HANDLER* _pUnmanaged;
public:
FreeImageStream(System::IO::Stream* stream)
{
FreeImage_SaveToHandle((FREE_IMAGE_FORMAT) 1,0,0,0,0);
_pUnmanaged = new struct UNMANAGED_HANDLER;
_pUnmanaged->_stream = stream;
}
~FreeImageStream()
{
_pUnmanaged->_stream = NULL;
delete _pUnmanaged;
}
bool SaveImage(FREE_IMAGE_FORMAT fif, unsigned int dib, int flags) {
return (bool)FreeImage_SaveToHandle(fif,(FIBITMAP*) dib,(FreeImageIO*)_pUnmanaged,(fi_handle)_pUnmanaged,flags);
}
unsigned int LoadImage(FREE_IMAGE_FORMAT fif, int flags) {
return (unsigned int)FreeImage_LoadFromHandle(fif,(FreeImageIO*)_pUnmanaged,(fi_handle)_pUnmanaged,flags);
}
};
}

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="FreeImageIO.Net"
ProjectGUID="{E87923FF-1FBD-450D-9287-539A90DE9776}"
RootNamespace="FreeImageIONet"
Keyword="ManagedCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
ManagedExtensions="TRUE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG"
MinimalRebuild="FALSE"
BasicRuntimeChecks="0"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
WarningLevel="3"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/noentry"
AdditionalDependencies="nochkclr.obj mscoree.lib msvcrt.lib FreeImaged.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
AssemblyDebug="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
ManagedExtensions="TRUE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl"
PreprocessorDefinitions="WIN32;NDEBUG"
MinimalRebuild="FALSE"
RuntimeLibrary="0"
UsePrecompiledHeader="3"
WarningLevel="3"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/noentry"
AdditionalDependencies="nochkclr.obj mscoree.lib msvcrt.lib FreeImage.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="1"
GenerateDebugInformation="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="mscorlib.dll"/>
<AssemblyReference
RelativePath="System.dll"/>
<AssemblyReference
RelativePath="System.Data.dll"/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\AssemblyInfo.cpp">
</File>
<File
RelativePath=".\FreeImageIO.Net.cpp">
</File>
<File
RelativePath=".\Stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\FreeImageIO.Net.h">
</File>
<File
RelativePath=".\resource.h">
</File>
<File
RelativePath=".\Stdafx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
<File
RelativePath=".\app.ico">
</File>
<File
RelativePath=".\app.rc">
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeImageIO.Net", "FreeImageIO.Net.vcproj", "{E87923FF-1FBD-450D-9287-539A90DE9776}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{E87923FF-1FBD-450D-9287-539A90DE9776}.Debug.ActiveCfg = Debug|Win32
{E87923FF-1FBD-450D-9287-539A90DE9776}.Debug.Build.0 = Debug|Win32
{E87923FF-1FBD-450D-9287-539A90DE9776}.Release.ActiveCfg = Release|Win32
{E87923FF-1FBD-450D-9287-539A90DE9776}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,27 @@
========================================================================
FreeImageIO.Net
Author: Marcos Pernambuco Motta (marcos.pernambuco@gmail.com)
========================================================================
This library allows programs that use FreeImage.Net to save images to or
to load images from .Net Streams.
The class FreeImageStream implements a FreeImageIO handler and routes
IO calls (read,write,tell and seek) to a wrapped System.IO.Stream.
Example:
using FreeImageAPI;
using FreeImageIODotNet;
uint dib = FreeImageAPI.FreeImage.Allocate(width,height,32,0,0,0);
// ... Image handling code goes here
System.IO.FileStream stream = new System.IO.FileStream(@"c:\sample.png",System.IO.FileMode.Create);
FreeImageStream imageStream = new FreeImageStream(stream);
imageStream.SaveImage((int)FREE_IMAGE_FORMAT.FIF_PNG,dib,0);
stream.Close();
Compile with VS2003.

View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// FreeImageIO.Net.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,6 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,52 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 9, 1
#pragma code_page(1252)
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc