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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
FreeImage .NET Wrapper Release Notes
The FreeImage .NET Wrapper included in the 3.14.1 release is still on version 3.13.1. It does not yet contain any new features or bug fixes. However, it is expected to work with the new FreeImage DLL with no problems.
The next version of FreeImage is expected to be released soon and will contain an updated .NET wrapper, including support for all new features, that have been introduced in this and the next version of FreeImage.
Regards, FreeImage .NET Wrapper Team

View File

@@ -0,0 +1,179 @@
using System;
using System.IO;
using FreeImageAPI;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Sample01
{
class Program
{
static void Main(string[] args)
{
// Check if FreeImage.dll is available (can be in %path%).
if (!FreeImage.IsAvailable())
{
Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
return;
}
Sample sample = new Sample();
// This example shows the basic loading and saving operations offered by FreeImage.
sample.Example01();
// This example shows a more comfortable way offered by the .NET Wrapper.
sample.Example02();
// This example shows the FreeImage-Errormessage-Callback
sample.Example03();
}
}
public class Sample
{
const string fileName = @"Sample.jpg";
const string outFileName = @"Sample.tif";
FIBITMAP dib = new FIBITMAP();
string message = null;
public void Example01()
{
if (!File.Exists(fileName))
{
Console.WriteLine(fileName + " does not exist. Aborting.");
return;
}
// Try to unload the bitmap handle (in case it is not null).
// Always assert that a handle (like dib) is unloaded before it is reused, because
// on unmanaged side there is no garbage collector that will clean up unreferenced
// objects.
// The following code will produce a memory leak (in case the bitmap is loaded
// successfully) because the handle to the first bitmap is lost:
// dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE);
// dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE);
if (!dib.IsNull)
FreeImage.Unload(dib);
// Loading a sample bitmap. In this case it's a .jpg file. 'Load' requires the file
// format or the loading process will fail. An additional flag (the default value is
// 'DEFAULT') can be set to enable special loading options.
dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, fileName, FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE);
// Check if the handle is null which means the bitmap could not be loaded.
if (dib.IsNull)
{
Console.WriteLine("Loading bitmap failed. Aborting.");
// Check whether there was an error message.
return;
}
// Try flipping the bitmap.
if (!FreeImage.FlipHorizontal(dib))
{
Console.WriteLine("Unable to flip bitmap.");
// Check whether there was an error message.
}
// Store the bitmap back to disk. Again the desired format is needed. In this case the format is 'TIFF'.
// An output filename has to be chosen (which will be overwritten without a warning).
// A flag can be provided to enable pluginfunctions (compression is this case).
FreeImage.Save(FREE_IMAGE_FORMAT.FIF_TIFF, dib, outFileName, FREE_IMAGE_SAVE_FLAGS.TIFF_DEFLATE);
// The bitmap was saved to disk but is still allocated in memory, so the handle has to be freed.
if (!dib.IsNull)
FreeImage.Unload(dib);
// Make sure to set the handle to null so that it is clear that the handle is not pointing to a bitmap.
dib.SetNull();
}
public void Example02()
{
// 'UnloadEx' is a comfortable way of unloading a bitmap. The coder can call 'UnloadEx' even
// when the handle is pointing to null (in this case nothing will happen). In case the handle
// is valid (valid means that it is NOT pointing to null) the bitmap will be unloaded and the
// handle will be set to null manually.
FreeImage.UnloadEx(ref dib);
// 'LoadEx' is a comfortable way of loading a bitmap. 'LoadEx' tries to find out the format of
// the file and will use this to load it. It will use DEFAULT loading values.
dib = FreeImage.LoadEx(fileName);
// Check if the handle is null which means the bitmap could not be loaded.
if (dib.IsNull)
{
Console.WriteLine("Loading bitmap failed. Aborting.");
return;
}
// 'SaveEx' (like 'LoadEx') will try to save the bitmap with default values.
// Before saving the bitmap, 'SaveEx' checks whether the extension is valid for the file type
// and if the plugin can use the colordepth of the bitmap. If not it will automatically convert
// the bitmap into the next best colordepth and save it.
if (!FreeImage.SaveEx(ref dib, @"Sample.gif", false))
{
Console.WriteLine("Saving bitmap failed.");
}
// The handle is still valid.
if (!FreeImage.SaveEx(
ref dib,
@"Sample", // No extension was selected so let 'SaveEx' decide.
FREE_IMAGE_FORMAT.FIF_PNG, // A format is needed this time.
FREE_IMAGE_SAVE_FLAGS.DEFAULT, // PNG has no options so use default.
FREE_IMAGE_COLOR_DEPTH.FICD_04_BPP, // 4bpp as result color depth.
true)) // We're done so unload
{
// SaveEx will not unload the bitmap in case saving failed.
// This way possible operations done to the bitmaps aren't lost.
FreeImage.UnloadEx(ref dib);
}
}
public void Example03()
{
// Safely unload to prevent memory leak.
FreeImage.UnloadEx(ref dib);
// Load the example bitmap.
dib = FreeImage.LoadEx(fileName);
// Check whether loading succeeded.
if (dib.IsNull)
{
return;
}
// Add this class to the callback event.
FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message);
// Try to save the bitmap as a gif
if (!FreeImage.Save(FREE_IMAGE_FORMAT.FIF_GIF, dib, @"Sample_fail.gif", FREE_IMAGE_SAVE_FLAGS.DEFAULT))
{
// Saving failed
// Check whether there was an error callback
if (message != null)
{
// Print the message and delete it.
Console.WriteLine("Error message recieved: {0}", message);
message = null;
}
}
// Unload bitmap.
FreeImage.UnloadEx(ref dib);
// Remove this class from the callback event.
FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message);
}
void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message)
{
this.message = message;
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("ac0569fe-c021-4f40-bfe9-275baf0fd21a")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,103 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0D294AB6-FAD4-4364-AAB6-43C1796116A9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample01</RootNamespace>
<AssemblyName>Sample01</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Sample.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -0,0 +1,140 @@
using System;
using System.IO;
using FreeImageAPI;
namespace Sample02
{
class Program
{
static void Main(string[] args)
{
// Check if FreeImage.dll is available (can be in %path%).
if (!FreeImage.IsAvailable())
{
Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
return;
}
Sample sample = new Sample();
sample.Example();
}
}
public class Sample
{
const string fileName = @"multipaged.tif";
FIMULTIBITMAP dib = new FIMULTIBITMAP();
Random rand = new Random();
public void Example()
{
if (!File.Exists(fileName))
{
Console.WriteLine("File not found. Aborting.");
return;
}
// Load the multipaged bitmap.
// 'OpenMultiBitmapEx' tries to find the correct file format, loads the bitmap
// with default options, with write support and does not use caching.
dib = FreeImage.OpenMultiBitmapEx(fileName);
// Check whether loading succeeded.
if (dib.IsNull)
{
Console.WriteLine("File could not be loaded. Aborting.");
return;
}
// Get the number of bitmaps the multipaged bitmap contains.
int count = FreeImage.GetPageCount(dib);
// Multipaged bitmaps consist of multiple single FIBITMAPs
FIBITMAP page = new FIBITMAP();
// There are bitmaps we can work with.
if (count > 0)
{
// Lock a random bitmap to work with.
page = FreeImage.LockPage(dib, rand.Next(0, count));
}
// Check whether locking succeeded.
if (page.IsNull)
{
// Locking failed. Unload the bitmap and return.
FreeImage.CloseMultiBitmapEx(ref dib);
return;
}
// Get a list of locked pages. This can be usefull to check whether a page has already been locked.
int[] lockedPages = FreeImage.GetLockedPages(dib);
// Lets modify the page.
if (FreeImage.AdjustGamma(page, 2d))
{
Console.WriteLine("Successfully changed gamma of page {0}.", lockedPages[0]);
}
else
{
Console.WriteLine("Failed to adjust gamma ...");
}
// Print out the list of locked pages
foreach (int i in lockedPages)
Console.WriteLine("Page {0} is locked.", i);
// Use 'UnlockPage' instead of 'Unload' to free the page. Set the third parameter to 'true'
// so that FreeImage can store the changed page within the multipaged bitmap.
FreeImage.UnlockPage(dib, page, true);
// Retieve the list again to see whether unlocking succeeded.
lockedPages = FreeImage.GetLockedPages(dib);
// No output should be produced here.
foreach (int i in lockedPages)
Console.WriteLine("Page {0} is still locked.", i);
// If there are more than one page we can swap them
if (count > 1)
{
if (!FreeImage.MovePage(dib, 1, 0))
{
Console.WriteLine("Swapping pages failed.");
}
}
if (count > 2)
{
// Lock page 2
page = FreeImage.LockPage(dib, 2);
if (!page.IsNull)
{
// Clone the page for later appending
FIBITMAP temp = FreeImage.Clone(page);
// Unlock the page again
FreeImage.UnlockPage(dib, page, false);
// Delete the page form the multipaged bitmap
FreeImage.DeletePage(dib, 2);
// Append the clone again
FreeImage.AppendPage(dib, temp);
// Check whether the number of pages is still the same
Console.WriteLine("Pages before: {0}. Pages after: {1}", count, FreeImage.GetPageCount(dib));
// Unload clone to prevent memory leak
FreeImage.UnloadEx(ref temp);
}
}
// We are done and close the multipaged bitmap.
if (!FreeImage.CloseMultiBitmapEx(ref dib))
{
Console.WriteLine("Closing bitmap failed!");
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("35960522-c01a-40d2-a86b-37b9839b131c")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,95 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AF8B72BD-1A8B-4E6B-A0F1-0BD57497777B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample02</RootNamespace>
<AssemblyName>Sample02</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="multipaged.tif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,74 @@
using System;
using System.IO;
using FreeImageAPI;
namespace Sample03
{
class Program
{
static void Main(string[] args)
{
// Check if FreeImage.dll is available (can be in %path%).
if (!FreeImage.IsAvailable())
{
Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
return;
}
// Add this class to the message event
FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message);
Sample sample = new Sample();
sample.Example();
// Remove this class from the message event
FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message);
}
static void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message)
{
Console.WriteLine("Error for {0}: {1}", fif.ToString(), message);
}
}
public class Sample
{
FIBITMAP dib = new FIBITMAP();
public void Example()
{
// Allocating a new bitmap with 99x99 pixels, 16-bit color depth and an allocation of 5 bits for each color.
dib = FreeImage.Allocate(99, 99, 16, FreeImage.FI16_555_RED_MASK, FreeImage.FI16_555_GREEN_MASK, FreeImage.FI16_555_BLUE_MASK);
// Saving bitmap.
if (!FreeImage.SaveEx(ref dib, "example01.bmp", true))
{
Console.WriteLine("Saving 'example.bmp' failed.");
FreeImage.UnloadEx(ref dib);
}
// Allocation a new bitmap with 71x33 pixels, 4-bit color depth. Bitmaps below 16-bit have paletts.
// Each pixel references an index within the palette wich contains the true color.
// Therefor no bit-masks are needed and can be set to 0.
dib = FreeImage.Allocate(71, 33, 4, 0, 0, 0);
// Saving bitmap.
if (!FreeImage.SaveEx(ref dib, "example02.tif", true))
{
Console.WriteLine("Saving 'example02.tif' failed.");
FreeImage.UnloadEx(ref dib);
}
// Allocation a new bitmap. This time 'AllocateT' is used because 'Allocate' can only create standard bitmaps.
// In this case a RGBF bitmap is created. Red, green and blue are represented by a float-value so no bit-masks are needed.
dib = FreeImage.AllocateT(FREE_IMAGE_TYPE.FIT_RGBF, 50, 75, 9, 0, 0, 0);
// Saving bitmap.
if (!FreeImage.SaveEx(ref dib, "example03.hdr", true))
{
Console.WriteLine("Saving 'example03.hdr' failed.");
FreeImage.UnloadEx(ref dib);
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7139f1dc-3312-4c76-aeb3-891f869409b3")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,89 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A7E452A1-1A43-47C4-8BF3-DA28E1402FB9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample03</RootNamespace>
<AssemblyName>Sample03</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,205 @@
namespace Sample04
{
partial class MainForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.bOpenFile = new System.Windows.Forms.Button();
this.lWidth = new System.Windows.Forms.Label();
this.lHeight = new System.Windows.Forms.Label();
this.lBPP = new System.Windows.Forms.Label();
this.lRedMask = new System.Windows.Forms.Label();
this.lGreenMask = new System.Windows.Forms.Label();
this.lBlueMask = new System.Windows.Forms.Label();
this.lImageType = new System.Windows.Forms.Label();
this.lDPIY = new System.Windows.Forms.Label();
this.lDPIX = new System.Windows.Forms.Label();
this.lFormat = new System.Windows.Forms.Label();
this.lHeader = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// ofd
//
this.ofd.Filter = "All files (*.*)|*.*";
//
// bOpenFile
//
this.bOpenFile.Location = new System.Drawing.Point(12, 358);
this.bOpenFile.Name = "bOpenFile";
this.bOpenFile.Size = new System.Drawing.Size(75, 23);
this.bOpenFile.TabIndex = 4;
this.bOpenFile.Text = "Open file";
this.bOpenFile.UseVisualStyleBackColor = true;
this.bOpenFile.Click += new System.EventHandler(this.bOpenFile_Click);
//
// lWidth
//
this.lWidth.AutoSize = true;
this.lWidth.Location = new System.Drawing.Point(9, 51);
this.lWidth.Name = "lWidth";
this.lWidth.Size = new System.Drawing.Size(46, 16);
this.lWidth.TabIndex = 0;
this.lWidth.Text = "Width:";
//
// lHeight
//
this.lHeight.AutoSize = true;
this.lHeight.Location = new System.Drawing.Point(9, 76);
this.lHeight.Name = "lHeight";
this.lHeight.Size = new System.Drawing.Size(53, 16);
this.lHeight.TabIndex = 1;
this.lHeight.Text = "Height: ";
//
// lBPP
//
this.lBPP.AutoSize = true;
this.lBPP.Location = new System.Drawing.Point(9, 101);
this.lBPP.Name = "lBPP";
this.lBPP.Size = new System.Drawing.Size(80, 16);
this.lBPP.TabIndex = 2;
this.lBPP.Text = "Color Depth:";
//
// lRedMask
//
this.lRedMask.AutoSize = true;
this.lRedMask.Location = new System.Drawing.Point(9, 129);
this.lRedMask.Name = "lRedMask";
this.lRedMask.Size = new System.Drawing.Size(68, 16);
this.lRedMask.TabIndex = 3;
this.lRedMask.Text = "Red Mask:";
//
// lGreenMask
//
this.lGreenMask.AutoSize = true;
this.lGreenMask.Location = new System.Drawing.Point(9, 188);
this.lGreenMask.Name = "lGreenMask";
this.lGreenMask.Size = new System.Drawing.Size(80, 16);
this.lGreenMask.TabIndex = 5;
this.lGreenMask.Text = "Green Mask:";
//
// lBlueMask
//
this.lBlueMask.AutoSize = true;
this.lBlueMask.Location = new System.Drawing.Point(9, 158);
this.lBlueMask.Name = "lBlueMask";
this.lBlueMask.Size = new System.Drawing.Size(70, 16);
this.lBlueMask.TabIndex = 6;
this.lBlueMask.Text = "Blue Mask:";
//
// lImageType
//
this.lImageType.AutoSize = true;
this.lImageType.Location = new System.Drawing.Point(9, 215);
this.lImageType.Name = "lImageType";
this.lImageType.Size = new System.Drawing.Size(81, 16);
this.lImageType.TabIndex = 7;
this.lImageType.Text = "Image Type:";
//
// lDPIY
//
this.lDPIY.AutoSize = true;
this.lDPIY.Location = new System.Drawing.Point(9, 244);
this.lDPIY.Name = "lDPIY";
this.lDPIY.Size = new System.Drawing.Size(43, 16);
this.lDPIY.TabIndex = 8;
this.lDPIY.Text = "DPI Y:";
//
// lDPIX
//
this.lDPIX.AutoSize = true;
this.lDPIX.Location = new System.Drawing.Point(9, 273);
this.lDPIX.Name = "lDPIX";
this.lDPIX.Size = new System.Drawing.Size(44, 16);
this.lDPIX.TabIndex = 9;
this.lDPIX.Text = "DPI X:";
//
// lFormat
//
this.lFormat.AutoSize = true;
this.lFormat.Location = new System.Drawing.Point(9, 302);
this.lFormat.Name = "lFormat";
this.lFormat.Size = new System.Drawing.Size(78, 16);
this.lFormat.TabIndex = 10;
this.lFormat.Text = "File Format:";
//
// lHeader
//
this.lHeader.AutoSize = true;
this.lHeader.Location = new System.Drawing.Point(117, 19);
this.lHeader.Name = "lHeader";
this.lHeader.Size = new System.Drawing.Size(162, 16);
this.lHeader.TabIndex = 11;
this.lHeader.Text = "Bitmap-Information Viewer";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(400, 393);
this.Controls.Add(this.lHeader);
this.Controls.Add(this.lFormat);
this.Controls.Add(this.lDPIX);
this.Controls.Add(this.lDPIY);
this.Controls.Add(this.lImageType);
this.Controls.Add(this.lBlueMask);
this.Controls.Add(this.lGreenMask);
this.Controls.Add(this.bOpenFile);
this.Controls.Add(this.lRedMask);
this.Controls.Add(this.lBPP);
this.Controls.Add(this.lHeight);
this.Controls.Add(this.lWidth);
this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sample04";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.Button bOpenFile;
private System.Windows.Forms.Label lWidth;
private System.Windows.Forms.Label lHeight;
private System.Windows.Forms.Label lBPP;
private System.Windows.Forms.Label lRedMask;
private System.Windows.Forms.Label lGreenMask;
private System.Windows.Forms.Label lBlueMask;
private System.Windows.Forms.Label lImageType;
private System.Windows.Forms.Label lDPIY;
private System.Windows.Forms.Label lDPIX;
private System.Windows.Forms.Label lFormat;
private System.Windows.Forms.Label lHeader;
}
}

View File

@@ -0,0 +1,120 @@
using System;
using System.Windows.Forms;
using FreeImageAPI;
namespace Sample04
{
public partial class MainForm : Form
{
string message = null;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
InitializeComponent();
FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message);
}
~MainForm()
{
FreeImageEngine.Message -= new OutputMessageFunction(FreeImage_Message);
}
void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message)
{
if (this.message == null)
{
this.message = message;
}
else
{
this.message += "\n" + message;
}
}
private void bOpenFile_Click(object sender, EventArgs e)
{
// Resetting filename
ofd.FileName = "";
// Was a file selected
if (ofd.ShowDialog() == DialogResult.OK)
{
// Format is stored in 'format' on successfull load.
FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_UNKNOWN;
// Try loading the file
FIBITMAP dib = FreeImage.LoadEx(ofd.FileName, ref format);
try
{
// Error handling
if (dib.IsNull)
{
// Chech whether FreeImage generated an error messe
if (message != null)
{
MessageBox.Show("File could not be loaded!\nError:{0}", message);
}
else
{
MessageBox.Show("File could not be loaded!", message);
}
return;
}
// Read width
lWidth.Text = String.Format("Width: {0}", FreeImage.GetWidth(dib));
// Read height
lHeight.Text = String.Format("Width: {0}", FreeImage.GetWidth(dib));
// Read color depth
lBPP.Text = String.Format("Color Depth: {0}", FreeImage.GetBPP(dib));
// Read red bitmask (16 - 32 bpp)
lRedMask.Text = String.Format("Red Mask: 0x{0:X8}", FreeImage.GetRedMask(dib));
// Read green bitmask (16 - 32 bpp)
lBlueMask.Text = String.Format("Green Mask: 0x{0:X8}", FreeImage.GetGreenMask(dib));
// Read blue bitmask (16 - 32 bpp)
lGreenMask.Text = String.Format("Blue Mask: 0x{0:X8}", FreeImage.GetBlueMask(dib));
// Read image type (FI_BITMAP, FIT_RGB16, FIT_COMPLEX ect)
lImageType.Text = String.Format("Image Type: {0}", FreeImage.GetImageType(dib));
// Read x-axis dpi
lDPIX.Text = String.Format("DPI X: {0}", FreeImage.GetResolutionX(dib));
// Read y-axis dpi
lDPIY.Text = String.Format("DPI Y: {0}", FreeImage.GetResolutionY(dib));
// Read file format
lFormat.Text = String.Format("File Format: {0}", FreeImage.GetFormatFromFIF(format));
}
catch
{
}
// Always unload bitmap
FreeImage.UnloadEx(ref dib);
// Reset the error massage buffer
message = null;
}
// No file was selected
else
{
MessageBox.Show("No file loaded.", "Error");
}
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ofd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7c8fdc9a-a8f9-4996-99c8-9df47513edeb")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,102 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1F4BCDD7-5BD9-4237-8B14-C52B2A9FF52A}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample04</RootNamespace>
<AssemblyName>Sample04</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,213 @@
using System;
using FreeImageAPI;
using System.Drawing;
namespace Sample05
{
class Program
{
static void Main(string[] args)
{
// Check if FreeImage.dll is available (can be in %path%).
if (!FreeImage.IsAvailable())
{
Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
return;
}
Sample sample = new Sample();
// The example will flip the bitmap by manually accessing the
// bitmaps scanlines and swapping them
sample.Example01();
// The example will access each pixel of the bitmap manually
// and change its color intensity to 3/4 of the original value
// which will have a darker bitmap as result.
sample.Example02();
// The example will access and swap the bitmaps palette from
// 'FIC_MINISBLACK' to 'FIC_MINISWHITE'. Then it will swap each pixels
// palette index so that each pixel is assigned to the its old value
// so that the bitmaps "pixeldata" stays the same.
sample.Example03();
}
}
public class Sample
{
FIBITMAP dib = new FIBITMAP();
public void Example01()
{
// Load sample file
dib = FreeImage.LoadEx("Sample.jpg", FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE);
// Check whether loading succeeded
if (dib.IsNull)
{
Console.WriteLine("Sample.jpg could not be loaded. Aborting.");
return;
}
// Check whether the bitmap has 24 bpp color depth to ensure
// using RGBTRIPPLE is correct.
if (FreeImage.GetBPP(dib) != 24)
{
Console.WriteLine("Sample.jpg is no 24 bpp bitmap. Aborting.");
FreeImage.UnloadEx(ref dib);
return;
}
// Store height of the bitmap
int height = (int)FreeImage.GetHeight(dib);
// Iterate over half of the bitmaps scanlines and swap
// line[1] with line[height], line[2] with line[height-1] etc which will
// flip the image.
for (int i = 0; i < (height / 2); i++)
{
// Get scanline from the bottom part of the bitmap
Scanline<RGBTRIPLE> scanlineBottom = new Scanline<RGBTRIPLE>(dib, i);
// Get scanline from the top part of the bitmap
Scanline<RGBTRIPLE> scanlineTop = new Scanline<RGBTRIPLE>(dib, height - 1 - i);
// Get arrays of RGBTRIPPLEs that contain the bitmaps real pixel data
// of the two scanlines.
RGBTRIPLE[] rgbtBottom = scanlineBottom.Data;
RGBTRIPLE[] rgbtTop = scanlineTop.Data;
// Restore the scanline across to switch the bitmaps lines.
scanlineBottom.Data = rgbtTop;
scanlineTop.Data = rgbtBottom;
}
// Store the bitmap to disk
if (!FreeImage.SaveEx(ref dib, "SampleOut01.jpg", FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD, true))
{
Console.WriteLine("Error while saving 'SampleOut01.jpg'");
FreeImage.UnloadEx(ref dib);
}
}
public void Example02()
{
dib = FreeImage.LoadEx("Sample.jpg", FREE_IMAGE_LOAD_FLAGS.JPEG_ACCURATE);
// Check whether loading succeeded
if (dib.IsNull)
{
Console.WriteLine("Sample.jpg could not be loaded. Aborting.");
return;
}
// Check whether the bitmap has 24 bpp color depth to ensure
// using RGBTRIPPLE is correct.
if (FreeImage.GetBPP(dib) != 24)
{
Console.WriteLine("Sample.jpg is no 24 bpp bitmap. Aborting.");
FreeImage.UnloadEx(ref dib);
return;
}
// Iterate over all scanlines
for (int i = 0; i < FreeImage.GetHeight(dib); i++)
{
// Get scanline
Scanline<RGBTRIPLE> scanline = new Scanline<RGBTRIPLE>(dib, i);
// Get pixeldata from scanline
RGBTRIPLE[] rgbt = scanline.Data;
// Iterate over each pixel reducing the colors intensity to 3/4 which
// will darken the bitmap.
for (int j = 0; j < rgbt.Length; j++)
{
rgbt[j].rgbtBlue = (byte)((int)rgbt[j].rgbtBlue * 3 / 4);
rgbt[j].rgbtGreen = (byte)((int)rgbt[j].rgbtGreen * 3 / 4);
rgbt[j].rgbtRed = (byte)((int)rgbt[j].rgbtRed * 3 / 4);
// In case no direct access to the data is implemented
// the following way is equivalent:
//
// Color color = rgbt[j].color;
// rgbt[j].color = Color.FromArgb(color.R * 3 / 4, color.G * 3 / 4, color.B * 3 / 4);
}
// Write the darkened scanline back to memory
scanline.Data = rgbt;
}
// Store the bitmap to disk
if (!FreeImage.SaveEx(ref dib, "SampleOut02.jpg", FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD, true))
{
Console.WriteLine("Error while saving 'SampleOut02.jpg'");
FreeImage.UnloadEx(ref dib);
}
}
public void Example03()
{
dib = FreeImage.LoadEx("Sample.tif");
// Check whether loading succeeded
if (dib.IsNull)
{
Console.WriteLine("Sample.tif could not be loaded. Aborting.");
return;
}
// Check whether the bitmap has 4 bpp color depth to ensure
// using FI4B is correct.
if (FreeImage.GetBPP(dib) != 4)
{
Console.WriteLine("Sample.tif is no 4 bpp bitmap. Aborting.");
FreeImage.UnloadEx(ref dib);
return;
}
// Get the bitmaps palette
Palette palette = FreeImage.GetPaletteEx(dib);
int size = (int)palette.Length;
// Check whether the palette has a color (is valid)
if (size == 0)
{
Console.WriteLine("Sample.tif has no valid palette. Aborting.");
FreeImage.UnloadEx(ref dib);
return;
}
// Swapping the palette
for (int i = 0; i < size / 2; i++)
{
RGBQUAD temp = palette[i];
palette[i] = palette[size - 1 - i];
palette[size - 1 - i] = temp;
}
// Iterate over each scanline
for (int i = 0; i < FreeImage.GetHeight(dib); i++)
{
// Get scanline
Scanline<FI4BIT> scanline = new Scanline<FI4BIT>(dib, i);
// Iterate over all pixels swapping the palette index
// so that the color will stay the same
for (int j = 0; j < scanline.Length; j++)
{
scanline[j] = (byte)(size - 1 - scanline[j]);
}
}
// Save the bitmap to disk
if (!FreeImage.SaveEx(ref dib, "SampleOut03.tif", FREE_IMAGE_SAVE_FLAGS.TIFF_LZW, true))
{
Console.WriteLine("Error while saving 'SampleOut03.tif'");
FreeImage.UnloadEx(ref dib);
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("fd43331d-5ea4-40f8-86d5-8f820d606912")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,98 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A501F134-8FB6-460B-AFE9-884A696C1C07}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample05</RootNamespace>
<AssemblyName>Sample05</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<None Include="Sample.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Sample.tif">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,120 @@
namespace Sample06
{
partial class MainForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.picBox = new System.Windows.Forms.PictureBox();
this.bExample01 = new System.Windows.Forms.Button();
this.bOriginal = new System.Windows.Forms.Button();
this.bExample02 = new System.Windows.Forms.Button();
this.bExample03 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.picBox)).BeginInit();
this.SuspendLayout();
//
// picBox
//
this.picBox.BackColor = System.Drawing.Color.White;
this.picBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picBox.Location = new System.Drawing.Point(12, 12);
this.picBox.Name = "picBox";
this.picBox.Size = new System.Drawing.Size(747, 465);
this.picBox.TabIndex = 0;
this.picBox.TabStop = false;
//
// bExample01
//
this.bExample01.Location = new System.Drawing.Point(93, 483);
this.bExample01.Name = "bExample01";
this.bExample01.Size = new System.Drawing.Size(88, 23);
this.bExample01.TabIndex = 1;
this.bExample01.Text = "Example 01";
this.bExample01.UseVisualStyleBackColor = true;
this.bExample01.Click += new System.EventHandler(this.bExample01_Click);
//
// bOriginal
//
this.bOriginal.Location = new System.Drawing.Point(12, 483);
this.bOriginal.Name = "bOriginal";
this.bOriginal.Size = new System.Drawing.Size(75, 23);
this.bOriginal.TabIndex = 2;
this.bOriginal.Text = "Original";
this.bOriginal.UseVisualStyleBackColor = true;
this.bOriginal.Click += new System.EventHandler(this.bOriginal_Click);
//
// bExample02
//
this.bExample02.Location = new System.Drawing.Point(187, 483);
this.bExample02.Name = "bExample02";
this.bExample02.Size = new System.Drawing.Size(88, 23);
this.bExample02.TabIndex = 3;
this.bExample02.Text = "Example 02";
this.bExample02.UseVisualStyleBackColor = true;
this.bExample02.Click += new System.EventHandler(this.bExample02_Click);
//
// bExample03
//
this.bExample03.Location = new System.Drawing.Point(281, 483);
this.bExample03.Name = "bExample03";
this.bExample03.Size = new System.Drawing.Size(88, 23);
this.bExample03.TabIndex = 4;
this.bExample03.Text = "Example 03";
this.bExample03.UseVisualStyleBackColor = true;
this.bExample03.Click += new System.EventHandler(this.bExample03_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(771, 518);
this.Controls.Add(this.bExample03);
this.Controls.Add(this.bExample02);
this.Controls.Add(this.bOriginal);
this.Controls.Add(this.bExample01);
this.Controls.Add(this.picBox);
this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sample06";
((System.ComponentModel.ISupportInitialize)(this.picBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox picBox;
private System.Windows.Forms.Button bExample01;
private System.Windows.Forms.Button bOriginal;
private System.Windows.Forms.Button bExample02;
private System.Windows.Forms.Button bExample03;
}
}

View File

@@ -0,0 +1,177 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using FreeImageAPI;
using System.Drawing.Imaging;
namespace Sample06
{
public partial class MainForm : Form
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
InitializeComponent();
}
private void bExample01_Click(object sender, EventArgs e)
{
// Load bitmap
FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");
// Check success
if (dib.IsNull)
{
MessageBox.Show("Could not load Sample.jpg", "Error");
return;
}
// Check whether bitmap is 24-bit
if (FreeImage.GetBPP(dib) != 24)
{
MessageBox.Show("Sample.jpg is not 24-bit.", "Error");
FreeImage.UnloadEx(ref dib);
return;
}
// Convert the 24-bit bitmap to 8-bit and forcing the result will be greyscale
dib = FreeImage.ConvertColorDepth(dib, FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP | FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE, true);
if (FreeImage.GetBPP(dib) == 8)
{
// Convert the FreeImage-Bitmap into a .NET bitmap
Bitmap bitmap = FreeImage.GetBitmap(dib);
// Dispose the bitmap of the pictureBox
if (picBox.Image != null)
{
picBox.Image.Dispose();
}
// Assign the bitmap to the picturebox
picBox.Image = bitmap;
}
// Unload source bitmap
FreeImage.UnloadEx(ref dib);
}
private void bOriginal_Click(object sender, EventArgs e)
{
// Load bitmap
FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");
// Check success
if (dib.IsNull)
{
MessageBox.Show("Could not load Sample.jpg", "Error");
return;
}
// Convert the FreeImage-Bitmap into a .NET bitmap
Bitmap bitmap = FreeImage.GetBitmap(dib);
// Check success
if (bitmap != null)
{
// Dispose old bitmap
if (picBox.Image != null)
{
picBox.Image.Dispose();
}
// Assign new bitmap
picBox.Image = bitmap;
}
// Unload bitmap
FreeImage.UnloadEx(ref dib);
}
private void bExample02_Click(object sender, EventArgs e)
{
FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");
// Check success
if (dib.IsNull)
{
MessageBox.Show("Could not load Sample.jpg", "Error");
return;
}
// Convert bitmap to 8 bit
dib = FreeImage.ConvertColorDepth(dib, FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP, true);
// Check whether conversion succeeded
if (FreeImage.GetBPP(dib) != 8)
{
MessageBox.Show("Converting Sample.jpg to 8-bit failed.", "Error");
FreeImage.UnloadEx(ref dib);
return;
}
// Convert the FreeImage-Bitmap into a .NET bitmap
Bitmap bitmap = FreeImage.GetBitmap(dib);
// Dispose old bitmap
if (picBox.Image != null)
{
picBox.Image.Dispose();
}
// Assign new bitmap
picBox.Image = bitmap;
// Unload bitmap
FreeImage.UnloadEx(ref dib);
}
private void bExample03_Click(object sender, EventArgs e)
{
// Load bitmap
Bitmap bitmap = (Bitmap)Bitmap.FromFile("Sample.jpg");
// Convert the .NET bitmap into a FreeImage-Bitmap
FIBITMAP dib = FreeImage.CreateFromBitmap(bitmap);
// Unload bitmap
bitmap.Dispose();
// Rescale the bitmap
FIBITMAP temp = FreeImage.Rescale(dib, 300, 300, FREE_IMAGE_FILTER.FILTER_BICUBIC);
// Unload bitmap
FreeImage.UnloadEx(ref dib);
Random rand = new Random();
// Rotate the bitmap
dib = FreeImage.Rotate(temp, rand.NextDouble() * 360d);
// Unload bitmap
FreeImage.UnloadEx(ref temp);
// Convert the FreeImage-Bitmap into a .NET bitmap
bitmap = FreeImage.GetBitmap(dib);
// Unload bitmap
FreeImage.UnloadEx(ref dib);
// Unload bitmap
if (picBox.Image != null)
{
picBox.Image.Dispose();
}
// Assign new bitmap
picBox.Image = bitmap;
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("69a8cbdd-43da-49e3-8d0b-2680c4ca2851")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,107 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E2EA945D-E22C-47B3-9DD9-3A0B07FA3F81}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample06</RootNamespace>
<AssemblyName>Sample06</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Sample.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using FreeImageAPI;
namespace Sample07
{
class Program
{
static void Main(string[] args)
{
// Check if FreeImage.dll is available (can be in %path%).
if (!FreeImage.IsAvailable())
{
Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
return;
}
Sample sample = new Sample();
// This example shows how to work with ICC-Profiles.
sample.Example();
}
}
public class Sample
{
public void Example()
{
// Load the sample bitmap.
FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");
// Check success
if (dib.IsNull)
{
Console.WriteLine("Sample.jpg could not be loaded. Aborting.");
return;
}
// Get the bitmaps ICC-Profile.
FIICCPROFILE icc = FreeImage.GetICCProfileEx(dib);
// Print the profiles address.
Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
// Print the profiles size
Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
// Create data for a new profile.
byte[] data = new byte[256];
for (int i = 0; i < data.Length; i++)
data[i] = (byte)i;
// Create the new profile
icc = new FIICCPROFILE(dib, data);
Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
// Create the new profile but only use the first 64 bytes
icc = new FIICCPROFILE(dib, data, 64);
Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
// CreateICCProfileEx(...) does the same as above
icc = FreeImage.CreateICCProfileEx(dib, data, 16);
Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
FreeImage.UnloadEx(ref dib);
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("c9991d1d-684a-4736-b088-369a216b35b6")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,94 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3B1BB976-64A7-41FD-B7E2-59104161AF7E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample07</RootNamespace>
<AssemblyName>Sample07</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Sample.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("dc891ffc-ab5c-451f-97da-2c0d5d90edcc")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,108 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{491042DB-495B-420C-A3BE-5D13019707C5}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample08</RootNamespace>
<AssemblyName>Sample08</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SampleForm.Designer.cs">
<DependentUpon>SampleForm.cs</DependentUpon>
</Compile>
<Compile Include="SerializationPlugin.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Sample.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SampleForm.resx">
<DependentUpon>SampleForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -0,0 +1,119 @@
namespace Sample08
{
partial class SampleForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.pictureBox = new System.Windows.Forms.PictureBox();
this.bLoad = new System.Windows.Forms.Button();
this.SaveToSer = new System.Windows.Forms.Button();
this.LoadSerBitmap = new System.Windows.Forms.Button();
this.bClearBitmap = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.pictureBox.Location = new System.Drawing.Point(12, 12);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(600, 400);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// bLoad
//
this.bLoad.Location = new System.Drawing.Point(12, 418);
this.bLoad.Name = "bLoad";
this.bLoad.Size = new System.Drawing.Size(98, 23);
this.bLoad.TabIndex = 1;
this.bLoad.Text = "Load any bitmap";
this.bLoad.UseVisualStyleBackColor = true;
this.bLoad.Click += new System.EventHandler(this.bLoad_Click);
//
// SaveToSer
//
this.SaveToSer.Location = new System.Drawing.Point(324, 418);
this.SaveToSer.Name = "SaveToSer";
this.SaveToSer.Size = new System.Drawing.Size(98, 23);
this.SaveToSer.TabIndex = 2;
this.SaveToSer.Text = "Save as .ser";
this.SaveToSer.UseVisualStyleBackColor = true;
this.SaveToSer.Click += new System.EventHandler(this.SaveToSer_Click);
//
// LoadSerBitmap
//
this.LoadSerBitmap.Location = new System.Drawing.Point(220, 418);
this.LoadSerBitmap.Name = "LoadSerBitmap";
this.LoadSerBitmap.Size = new System.Drawing.Size(98, 23);
this.LoadSerBitmap.TabIndex = 3;
this.LoadSerBitmap.Text = "Load .ser bitmap";
this.LoadSerBitmap.UseVisualStyleBackColor = true;
this.LoadSerBitmap.Click += new System.EventHandler(this.LoadSerBitmap_Click);
//
// bClearBitmap
//
this.bClearBitmap.Location = new System.Drawing.Point(116, 418);
this.bClearBitmap.Name = "bClearBitmap";
this.bClearBitmap.Size = new System.Drawing.Size(98, 23);
this.bClearBitmap.TabIndex = 4;
this.bClearBitmap.Text = "Clear screen";
this.bClearBitmap.UseVisualStyleBackColor = true;
this.bClearBitmap.Click += new System.EventHandler(this.bClearBitmap_Click);
//
// SampleForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(627, 448);
this.Controls.Add(this.bClearBitmap);
this.Controls.Add(this.LoadSerBitmap);
this.Controls.Add(this.SaveToSer);
this.Controls.Add(this.bLoad);
this.Controls.Add(this.pictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SampleForm";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sample 08";
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button bLoad;
private System.Windows.Forms.Button SaveToSer;
private System.Windows.Forms.Button LoadSerBitmap;
private System.Windows.Forms.Button bClearBitmap;
}
}

View File

@@ -0,0 +1,217 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FreeImageAPI;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace Sample08
{
public partial class SampleForm : Form
{
SerializationPlugin serialPlugin;
[STAThread]
static void Main()
{
// Check if FreeImage is available
if (!FreeImage.IsAvailable())
{
throw new Exception("FreeImage is not available!");
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SampleForm());
}
public SampleForm()
{
InitializeComponent();
FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message);
// Creating a new instance of the plugin will register it automatically.
serialPlugin = new SerializationPlugin();
}
void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message)
{
// Show the message
MessageBox.Show(String.Format("Format: {0}\nMessage: {1}", fif, message), "FreeImage Message");
}
private void bLoad_Click(object sender, EventArgs e)
{
// Create a new dialog instance
OpenFileDialog ofd = new OpenFileDialog();
try
{
// Apply settings
ofd.CheckPathExists = true;
ofd.CheckFileExists = true;
ofd.RestoreDirectory = true;
ofd.Filter = "All files (*.*)|*.*";
// Get filename
if (ofd.ShowDialog(this) == DialogResult.OK)
{
Bitmap bitmap = null;
try
{
// Try loading the selected file
// a ser-file will create an exception
bitmap = (Bitmap)Bitmap.FromFile(ofd.FileName);
}
catch
{
MessageBox.Show("Unable to load bitmap from file.", "Error");
return;
}
// Unload old bitmap
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
}
// Set new bitmap
pictureBox.Image = bitmap;
MessageBox.Show("Bitmap loaded successfully", "Success");
}
else
{
MessageBox.Show("Action aborted.");
}
}
finally
{
// Unload dialog
ofd.Dispose();
}
}
private void LoadSerBitmap_Click(object sender, EventArgs e)
{
// Creat a new dialog
OpenFileDialog ofd = new OpenFileDialog();
FIBITMAP dib = new FIBITMAP();
try
{
// Apply settings
ofd.CheckPathExists = true;
ofd.CheckFileExists = true;
ofd.RestoreDirectory = true;
ofd.Filter = "Serialized bitmap (*.ser)|*.ser";
// Get filename
if (ofd.ShowDialog() == DialogResult.OK)
{
// Try loading the file forcing the new format
dib = FreeImage.Load(serialPlugin.Format, ofd.FileName, FREE_IMAGE_LOAD_FLAGS.DEFAULT);
if (dib.IsNull)
{
MessageBox.Show("Loading bitmap failed", "Error");
return;
}
// Convert the loaded bitmap into a .NET bitmap
Bitmap bitmap = FreeImage.GetBitmap(dib);
if (bitmap == null)
{
MessageBox.Show("Converting bitmap failed.", "Error");
return;
}
// Unload the picturebox
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
}
// Apply the loaded bitmap
pictureBox.Image = bitmap;
MessageBox.Show("Bitmap loaded successfully", "Success");
}
else
{
MessageBox.Show("Action aborted.");
}
}
finally
{
// Unload bitmap
FreeImage.UnloadEx(ref dib);
// Unload dialog
ofd.Dispose();
}
}
private void SaveToSer_Click(object sender, EventArgs e)
{
// Create a new dialog
SaveFileDialog sfd = new SaveFileDialog();
FIBITMAP dib = new FIBITMAP();
try
{
// Check if the picture box contains a bitmap that can be saved.
if (pictureBox.Image == null)
{
MessageBox.Show("No bitmap loaded.", "Error");
return;
}
// Convert the picture-boxes bitmap into a FreeImage bitmap.
dib = FreeImage.CreateFromBitmap((Bitmap)pictureBox.Image);
if (dib.IsNull)
{
MessageBox.Show("Unable to convert bitmap to FIBITMAP.", "Error");
return;
}
// Apply settings
sfd.Filter = "Serialized bitmap (*.ser)|*.ser";
sfd.FileName = "Bitmap.ser";
sfd.OverwritePrompt = true;
sfd.RestoreDirectory = true;
// Get filename
if (sfd.ShowDialog() == DialogResult.OK)
{
// Save bitmap in the new format
if (FreeImage.SaveEx(dib, sfd.FileName, serialPlugin.Format))
MessageBox.Show("Bitmap saved successfully.", "Success");
else
MessageBox.Show("Saving bitmap failed.", "Failure");
}
else
{
MessageBox.Show("Action aborted.");
}
}
finally
{
// Unload bitmap
FreeImage.UnloadEx(ref dib);
// Unload dialog
sfd.Dispose();
}
}
private void bClearBitmap_Click(object sender, EventArgs e)
{
// Unload the picture-box
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
pictureBox.Image = null;
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,222 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.IO.Compression;
using FreeImageAPI;
using FreeImageAPI.IO;
using FreeImageAPI.Plugins;
namespace Sample08
{
public sealed class SerializationPlugin : LocalPlugin
{
// Header for the file
private byte[] header = new byte[] { 0xff, 0x12, 0x0f, 0xff, 0x01, 0x00 };
// Structure that will store all bitmap data.
[Serializable]
private struct SerialDib
{
public uint width;
public uint height;
public int pitch;
public uint bpp;
public uint red_mask;
public uint green_mask;
public uint blue_mask;
public byte[] data;
}
// Implementation of 'GetImplementedMethods()'
// All implemented methods are listed.
protected override LocalPlugin.MethodFlags GetImplementedMethods()
{
return
MethodFlags.DescriptionProc |
MethodFlags.SupportsExportBPPProc |
MethodFlags.SupportsExportTypeProc |
MethodFlags.SupportsICCProfilesProc |
MethodFlags.LoadProc |
MethodFlags.SaveProc |
MethodFlags.ValidateProc |
MethodFlags.ExtensionListProc;
}
// Returns a format string.
protected override string FormatProc()
{
return "Serialization";
}
// Returns a more specific description
protected override string DescriptionProc()
{
return "Serializes bitmaps for .NET";
}
// Returns whether a color depth is supported.
protected override bool SupportsExportBPPProc(int bpp)
{
return ((bpp == 1) ||
(bpp == 4) ||
(bpp == 8) ||
(bpp == 16) ||
(bpp == 24) ||
(bpp == 32));
}
// This plugin can only export standard bitmaps
protected override bool SupportsExportTypeProc(FREE_IMAGE_TYPE type)
{
return (type == FREE_IMAGE_TYPE.FIT_BITMAP);
}
// This plugin does not support icc profiles
protected override bool SupportsICCProfilesProc()
{
return false;
}
// The function reads the first bytes of the file and compares it
// with the predefined header.
protected override bool ValidateProc(ref FreeImageIO io, fi_handle handle)
{
for (int i = 0; i < header.Length; i++)
if (ReadByte(io, handle) != header[i])
return false;
return true;
}
// Loading function
protected override FIBITMAP LoadProc(ref FreeImageIO io, fi_handle handle, int page, int flags, IntPtr data)
{
// Check if the data has the correct format
if (!ValidateProc(ref io, handle))
{
// Create a free-image message
FreeImage.OutputMessageProc(format, "Invalid format.");
// return 0 (operation failed)
return FIBITMAP.Zero;
}
SerialDib sdib;
int read = 0;
System.IO.MemoryStream stream = new System.IO.MemoryStream();
byte[] buffer = new byte[1024];
do
{
// Use the helper function 'Read' to read from the source
read = Read(io, handle, 1, 1024, ref buffer);
// Store the data in a temporary buffer
stream.Write(buffer, 0, read);
}
while (read != 0);
// Set the memory stream back to the beginning.
stream.Position = 0;
// Unzip the stream
GZipStream zipStream = new GZipStream(stream, CompressionMode.Decompress);
// Create a serializer
BinaryFormatter formatter = new BinaryFormatter();
// Deserialize the stream
sdib = (SerialDib)formatter.Deserialize(zipStream);
// Unload the stream
zipStream.Dispose();
// Use 'ConvertFromRawBits and the deserialized struct to recreate the bitmap
// In this case the marshaller is used to create the needed IntPtr to the data
// array.
FIBITMAP dib = FreeImage.ConvertFromRawBits(
Marshal.UnsafeAddrOfPinnedArrayElement(sdib.data, 0),
(int)sdib.width, (int)sdib.height, sdib.pitch, sdib.bpp,
sdib.red_mask, sdib.green_mask, sdib.blue_mask,
false);
// Unload the temporary stream
stream.Dispose();
// Return the created bitmap
return dib;
}
// Saving function
protected override bool SaveProc(ref FreeImageIO io, FIBITMAP dib, fi_handle handle, int page, int flags, IntPtr data)
{
SerialDib sdib;
uint size = FreeImage.GetDIBSize(dib);
// Store all data needed to recreate the bitmap
sdib.width = FreeImage.GetWidth(dib);
sdib.height = FreeImage.GetHeight(dib);
sdib.pitch = (int)FreeImage.GetPitch(dib);
sdib.bpp = FreeImage.GetBPP(dib);
sdib.red_mask = FreeImage.GetRedMask(dib);
sdib.green_mask = FreeImage.GetGreenMask(dib);
sdib.blue_mask = FreeImage.GetBlueMask(dib);
sdib.data = new byte[size];
// Copy the bitmaps data into the structures byte-array
// The marshaller is used to create an IntPtr for using
// 'ConvertToRawBits'.
FreeImage.ConvertToRawBits(Marshal.UnsafeAddrOfPinnedArrayElement(sdib.data, 0),
dib, sdib.pitch, sdib.bpp,
sdib.red_mask, sdib.green_mask, sdib.blue_mask,
false);
// Use the healper function to write the header to the destination
if (Write(io, handle, (uint)header.Length, 1, ref header) != 1)
return false;
// Create a serializer
BinaryFormatter formatter = new BinaryFormatter();
// Create a temporary stream
MemoryStream stream = new MemoryStream();
// Create a compression stream
GZipStream zipStream = new GZipStream(stream, CompressionMode.Compress);
// Serialize the structure into the compression stream
formatter.Serialize(zipStream, sdib);
// Unload the compression stream
zipStream.Dispose();
// Get the result data
byte[] buffer = stream.GetBuffer();
// Use the healper function 'Write' to write the data to the destination
if (Write(io, handle, 1, (uint)buffer.Length, ref buffer) != buffer.Length)
{
// Unload the temporary stream
stream.Dispose();
return false;
}
// Unload the temporary stream
stream.Dispose();
return true;
}
// Return a list of supported file extensions (comma seperated)
protected override string ExtensionListProc()
{
return "ser";
}
// Implementation of 'ToString()'
public override string ToString()
{
return DescriptionProc();
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7f29fbaa-d2b3-4011-b34f-5a109bc282af")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,103 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{92A454B2-67EF-4B70-99C9-F22B83B6FBFF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample09</RootNamespace>
<AssemblyName>Sample09</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SampleForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SampleForm.Designer.cs">
<DependentUpon>SampleForm.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SampleForm.resx">
<SubType>Designer</SubType>
<DependentUpon>SampleForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,115 @@
namespace Sample09
{
partial class SampleForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.picBox = new System.Windows.Forms.PictureBox();
this.tbURL = new System.Windows.Forms.TextBox();
this.lUrl = new System.Windows.Forms.Label();
this.bLoadUrl = new System.Windows.Forms.Button();
this.bSave = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.picBox)).BeginInit();
this.SuspendLayout();
//
// picBox
//
this.picBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picBox.Location = new System.Drawing.Point(12, 12);
this.picBox.Name = "picBox";
this.picBox.Size = new System.Drawing.Size(536, 299);
this.picBox.TabIndex = 0;
this.picBox.TabStop = false;
//
// tbURL
//
this.tbURL.Location = new System.Drawing.Point(155, 317);
this.tbURL.Name = "tbURL";
this.tbURL.Size = new System.Drawing.Size(393, 20);
this.tbURL.TabIndex = 1;
this.tbURL.Text = "http://freeimage.sourceforge.net/images/logo.jpg";
//
// lUrl
//
this.lUrl.AutoSize = true;
this.lUrl.Location = new System.Drawing.Point(9, 320);
this.lUrl.Name = "lUrl";
this.lUrl.Size = new System.Drawing.Size(137, 13);
this.lUrl.TabIndex = 2;
this.lUrl.Text = "Enter the URL of an Image:";
//
// bLoadUrl
//
this.bLoadUrl.Location = new System.Drawing.Point(12, 344);
this.bLoadUrl.Name = "bLoadUrl";
this.bLoadUrl.Size = new System.Drawing.Size(75, 23);
this.bLoadUrl.TabIndex = 3;
this.bLoadUrl.Text = "Load URL";
this.bLoadUrl.UseVisualStyleBackColor = true;
this.bLoadUrl.Click += new System.EventHandler(this.bLoadUrl_Click);
//
// bSave
//
this.bSave.Location = new System.Drawing.Point(93, 344);
this.bSave.Name = "bSave";
this.bSave.Size = new System.Drawing.Size(75, 23);
this.bSave.TabIndex = 4;
this.bSave.Text = "Save to disk";
this.bSave.UseVisualStyleBackColor = true;
this.bSave.Click += new System.EventHandler(this.bSave_Click);
//
// SampleForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(560, 379);
this.Controls.Add(this.bSave);
this.Controls.Add(this.bLoadUrl);
this.Controls.Add(this.lUrl);
this.Controls.Add(this.tbURL);
this.Controls.Add(this.picBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SampleForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sample09";
((System.ComponentModel.ISupportInitialize)(this.picBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox picBox;
private System.Windows.Forms.TextBox tbURL;
private System.Windows.Forms.Label lUrl;
private System.Windows.Forms.Button bLoadUrl;
private System.Windows.Forms.Button bSave;
}
}

View File

@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FreeImageAPI;
using System.Net;
using System.IO;
namespace Sample09
{
public partial class SampleForm : Form
{
[STAThread]
static void Main()
{
// Check if FreeImage is available
if (!FreeImage.IsAvailable())
{
throw new Exception("FreeImage is not available!");
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SampleForm());
}
public SampleForm()
{
InitializeComponent();
}
private void bLoadUrl_Click(object sender, EventArgs e)
{
// Verify url
if (String.IsNullOrEmpty(tbURL.Text))
{
MessageBox.Show("Please enter a valid URL.", "Error");
return;
}
FIBITMAP dib = new FIBITMAP();
Stream sourceStream = null;
try
{
// Build a stream to read from
WebRequest request = (WebRequest)HttpWebRequest.Create(tbURL.Text);
WebResponse response = request.GetResponse();
sourceStream = response.GetResponseStream();
if (sourceStream == null)
{
throw new Exception();
}
// Load the image from stream
dib = FreeImage.LoadFromStream(sourceStream);
// Check success
if (dib.IsNull)
{
throw new Exception();
}
// Convert the bitmap into a .NET bitmap
Bitmap bitmap = FreeImage.GetBitmap(dib);
if (bitmap == null)
{
throw new Exception();
}
// Show the bitmap
if (picBox.Image != null)
{
picBox.Image.Dispose();
}
picBox.Image = bitmap;
}
catch
{
// Error handling
MessageBox.Show("Error loading URL.", "Error");
}
finally
{
// Clean up memory
FreeImage.UnloadEx(ref dib);
if (sourceStream != null) sourceStream.Dispose();
}
}
private void bSave_Click(object sender, EventArgs e)
{
// Check if there is a loaded bitmap
if (picBox.Image == null)
{
MessageBox.Show("No image loaded.", "Error");
return;
}
SaveFileDialog sfd = null;
FileStream fStream = null;
FIBITMAP dib = new FIBITMAP();
try
{
sfd = new SaveFileDialog();
sfd.CreatePrompt = false;
sfd.FileName = "";
sfd.Filter = "TIF (*tif)|*.tif";
sfd.OverwritePrompt = true;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
// Convert the .NET bitmap into a FreeImage-Bitmap
dib = FreeImage.CreateFromBitmap((Bitmap)picBox.Image);
if (dib.IsNull)
{
throw new Exception();
}
// Create a filestream to write to
fStream = new FileStream(sfd.FileName, FileMode.Create);
if (!FreeImage.SaveToStream(
ref dib,
fStream,
FREE_IMAGE_FORMAT.FIF_TIFF,
FREE_IMAGE_SAVE_FLAGS.TIFF_LZW,
FREE_IMAGE_COLOR_DEPTH.FICD_AUTO,
false))
{
throw new Exception();
}
MessageBox.Show("Image saved successfully.", "Success");
}
else
{
MessageBox.Show("Operation aborted.", "Aborted");
}
}
catch
{
MessageBox.Show("Error saving image.", "Error");
}
finally
{
// Clean up
if (sfd != null) sfd.Dispose();
if (fStream != null) fStream.Dispose();
FreeImage.UnloadEx(ref dib);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,87 @@
namespace Sample10
{
partial class MainForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.bLoad = new System.Windows.Forms.Button();
this.bQuit = new System.Windows.Forms.Button();
this.tvMetadata = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// bLoad
//
this.bLoad.Location = new System.Drawing.Point(12, 336);
this.bLoad.Name = "bLoad";
this.bLoad.Size = new System.Drawing.Size(75, 23);
this.bLoad.TabIndex = 0;
this.bLoad.Text = "Load Image";
this.bLoad.UseVisualStyleBackColor = true;
this.bLoad.Click += new System.EventHandler(this.bLoad_Click);
//
// bQuit
//
this.bQuit.Location = new System.Drawing.Point(328, 336);
this.bQuit.Name = "bQuit";
this.bQuit.Size = new System.Drawing.Size(75, 23);
this.bQuit.TabIndex = 1;
this.bQuit.Text = "Quit";
this.bQuit.UseVisualStyleBackColor = true;
this.bQuit.Click += new System.EventHandler(this.bQuit_Click);
//
// tvMetadata
//
this.tvMetadata.Location = new System.Drawing.Point(12, 12);
this.tvMetadata.Name = "tvMetadata";
this.tvMetadata.Size = new System.Drawing.Size(389, 318);
this.tvMetadata.TabIndex = 2;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(415, 371);
this.Controls.Add(this.tvMetadata);
this.Controls.Add(this.bQuit);
this.Controls.Add(this.bLoad);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MainForm";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button bLoad;
private System.Windows.Forms.Button bQuit;
private System.Windows.Forms.TreeView tvMetadata;
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using FreeImageAPI;
using FreeImageAPI.Metadata;
namespace Sample10
{
public partial class MainForm : Form
{
[STAThread]
static void Main()
{
// Check if FreeImage.dll is available
if (!FreeImage.IsAvailable())
{
MessageBox.Show("FreeImage is not available. Aborting.", "Error");
}
// Add this class to the FreeImage-Message-Callback
FreeImageEngine.Message += new OutputMessageFunction(FreeImage_Message);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
static void FreeImage_Message(FREE_IMAGE_FORMAT fif, string message)
{
// Display the data
MessageBox.Show(
String.Format("FreeImage-Message:\n{1}\nFormat:{0}", fif.ToString(), message),
"FreeImage-Message");
}
public MainForm()
{
InitializeComponent();
}
private void bQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void bLoad_Click(object sender, EventArgs e)
{
// Create variables
OpenFileDialog ofd = new OpenFileDialog();
FIBITMAP dib = new FIBITMAP();
try
{
// Apply settings
ofd.CheckFileExists = true;
ofd.CheckPathExists = true;
ofd.FileName = "";
ofd.Filter = "All files (*.*)|*.*";
ofd.Multiselect = false;
ofd.RestoreDirectory = true;
// Get image filename
if (ofd.ShowDialog() == DialogResult.OK)
{
// Load the image
dib = FreeImage.LoadEx(ofd.FileName);
// Check if image was loaded successfully
if (dib.IsNull) throw new Exception("Failed to load image.");
// Clear the treeview
tvMetadata.Nodes.Clear();
// Create a wrapper for all metadata the image contains
ImageMetadata iMetadata = new ImageMetadata(dib);
// Get each metadata model
foreach (MetadataModel metadataModel in iMetadata)
{
// Create a new node for each model
TreeNode modelNode = tvMetadata.Nodes.Add(metadataModel.ToString());
// Get each metadata tag and create a subnode for it
foreach (MetadataTag metadataTag in metadataModel)
{
modelNode.Nodes.Add(metadataTag.Key + ": " + metadataTag.ToString());
}
}
}
else
{
MessageBox.Show("Operation aborted.", "Aborted");
}
}
// Display error message
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
MessageBox.Show(ex.ToString(), "Exception caught");
}
// Clean up
finally
{
ofd.Dispose();
FreeImage.UnloadEx(ref dib);
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("e8da4fa8-cc15-4b0e-8c57-d55ceb771559")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,101 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{55DCC37A-E56C-44D9-9C44-8DAB10CD3003}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample10</RootNamespace>
<AssemblyName>Sample10</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,382 @@
namespace Sample11
{
partial class MainForm
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.pictureBox = new System.Windows.Forms.PictureBox();
this.bLoadImage = new System.Windows.Forms.Button();
this.bSaveImage = new System.Windows.Forms.Button();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.sfd = new System.Windows.Forms.SaveFileDialog();
this.lWidth = new System.Windows.Forms.Label();
this.lHeight = new System.Windows.Forms.Label();
this.lBpp = new System.Windows.Forms.Label();
this.lMetadataCount = new System.Windows.Forms.Label();
this.bGreyscale = new System.Windows.Forms.Button();
this.cbSelectFrame = new System.Windows.Forms.ComboBox();
this.lComment = new System.Windows.Forms.Label();
this.bAdjustGamma = new System.Windows.Forms.Button();
this.vGamma = new System.Windows.Forms.NumericUpDown();
this.bRedChannelOnly = new System.Windows.Forms.Button();
this.bBlueChannel = new System.Windows.Forms.Button();
this.bGreenChannel = new System.Windows.Forms.Button();
this.bAllChannels = new System.Windows.Forms.Button();
this.lSelectFrame = new System.Windows.Forms.Label();
this.lImageFormat = new System.Windows.Forms.Label();
this.bRotate = new System.Windows.Forms.Button();
this.vRotate = new System.Windows.Forms.TrackBar();
this.lRotate = new System.Windows.Forms.Label();
this.lColors = new System.Windows.Forms.Label();
this.nShowMetadata = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.vGamma)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.vRotate)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox.Location = new System.Drawing.Point(14, 15);
this.pictureBox.Margin = new System.Windows.Forms.Padding(4);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(542, 395);
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// bLoadImage
//
this.bLoadImage.Location = new System.Drawing.Point(564, 15);
this.bLoadImage.Margin = new System.Windows.Forms.Padding(4);
this.bLoadImage.Name = "bLoadImage";
this.bLoadImage.Size = new System.Drawing.Size(125, 28);
this.bLoadImage.TabIndex = 1;
this.bLoadImage.Text = "Load image";
this.bLoadImage.UseVisualStyleBackColor = true;
this.bLoadImage.Click += new System.EventHandler(this.bLoadImage_Click);
//
// bSaveImage
//
this.bSaveImage.Location = new System.Drawing.Point(564, 51);
this.bSaveImage.Margin = new System.Windows.Forms.Padding(4);
this.bSaveImage.Name = "bSaveImage";
this.bSaveImage.Size = new System.Drawing.Size(125, 28);
this.bSaveImage.TabIndex = 2;
this.bSaveImage.Text = "Save image";
this.bSaveImage.UseVisualStyleBackColor = true;
this.bSaveImage.Click += new System.EventHandler(this.bSaveImage_Click);
//
// ofd
//
this.ofd.AddExtension = false;
this.ofd.AutoUpgradeEnabled = false;
this.ofd.Filter = "All files|*.*";
this.ofd.RestoreDirectory = true;
this.ofd.SupportMultiDottedExtensions = true;
//
// sfd
//
this.sfd.AddExtension = false;
this.sfd.Filter = "All files|*.*";
this.sfd.RestoreDirectory = true;
this.sfd.SupportMultiDottedExtensions = true;
//
// lWidth
//
this.lWidth.AutoSize = true;
this.lWidth.Location = new System.Drawing.Point(563, 350);
this.lWidth.Name = "lWidth";
this.lWidth.Size = new System.Drawing.Size(57, 16);
this.lWidth.TabIndex = 6;
this.lWidth.Text = "Width: 0";
//
// lHeight
//
this.lHeight.AutoSize = true;
this.lHeight.Location = new System.Drawing.Point(649, 350);
this.lHeight.Name = "lHeight";
this.lHeight.Size = new System.Drawing.Size(60, 16);
this.lHeight.TabIndex = 7;
this.lHeight.Text = "Height: 0";
//
// lBpp
//
this.lBpp.AutoSize = true;
this.lBpp.Location = new System.Drawing.Point(740, 350);
this.lBpp.Name = "lBpp";
this.lBpp.Size = new System.Drawing.Size(45, 16);
this.lBpp.TabIndex = 8;
this.lBpp.Text = "Bpp: 0";
//
// lMetadataCount
//
this.lMetadataCount.AutoSize = true;
this.lMetadataCount.Location = new System.Drawing.Point(809, 350);
this.lMetadataCount.Name = "lMetadataCount";
this.lMetadataCount.Size = new System.Drawing.Size(77, 16);
this.lMetadataCount.TabIndex = 9;
this.lMetadataCount.Text = "Metadata: 0";
//
// bGreyscale
//
this.bGreyscale.Location = new System.Drawing.Point(564, 121);
this.bGreyscale.Name = "bGreyscale";
this.bGreyscale.Size = new System.Drawing.Size(125, 28);
this.bGreyscale.TabIndex = 10;
this.bGreyscale.Text = "Conv to greyscale";
this.bGreyscale.UseVisualStyleBackColor = true;
this.bGreyscale.Click += new System.EventHandler(this.bGreyscale_Click);
//
// cbSelectFrame
//
this.cbSelectFrame.FormattingEnabled = true;
this.cbSelectFrame.Location = new System.Drawing.Point(695, 156);
this.cbSelectFrame.Name = "cbSelectFrame";
this.cbSelectFrame.Size = new System.Drawing.Size(121, 24);
this.cbSelectFrame.TabIndex = 11;
this.cbSelectFrame.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// lComment
//
this.lComment.AutoSize = true;
this.lComment.Location = new System.Drawing.Point(563, 373);
this.lComment.Name = "lComment";
this.lComment.Size = new System.Drawing.Size(107, 16);
this.lComment.TabIndex = 12;
this.lComment.Text = "Image-comment:";
//
// bAdjustGamma
//
this.bAdjustGamma.Location = new System.Drawing.Point(564, 185);
this.bAdjustGamma.Name = "bAdjustGamma";
this.bAdjustGamma.Size = new System.Drawing.Size(125, 28);
this.bAdjustGamma.TabIndex = 13;
this.bAdjustGamma.Text = "Adjust gamma";
this.bAdjustGamma.UseVisualStyleBackColor = true;
this.bAdjustGamma.Click += new System.EventHandler(this.bAdjustGamma_Click);
//
// vGamma
//
this.vGamma.DecimalPlaces = 2;
this.vGamma.Increment = new decimal(new int[] {
0,
0,
0,
0});
this.vGamma.Location = new System.Drawing.Point(695, 189);
this.vGamma.Maximum = new decimal(new int[] {
2,
0,
0,
0});
this.vGamma.Name = "vGamma";
this.vGamma.Size = new System.Drawing.Size(121, 23);
this.vGamma.TabIndex = 14;
//
// bRedChannelOnly
//
this.bRedChannelOnly.Location = new System.Drawing.Point(564, 219);
this.bRedChannelOnly.Name = "bRedChannelOnly";
this.bRedChannelOnly.Size = new System.Drawing.Size(125, 28);
this.bRedChannelOnly.TabIndex = 15;
this.bRedChannelOnly.Text = "Red channel";
this.bRedChannelOnly.UseVisualStyleBackColor = true;
this.bRedChannelOnly.Click += new System.EventHandler(this.bRedChannelOnly_Click);
//
// bBlueChannel
//
this.bBlueChannel.Location = new System.Drawing.Point(564, 287);
this.bBlueChannel.Name = "bBlueChannel";
this.bBlueChannel.Size = new System.Drawing.Size(125, 28);
this.bBlueChannel.TabIndex = 16;
this.bBlueChannel.Text = "Blue channel";
this.bBlueChannel.UseVisualStyleBackColor = true;
this.bBlueChannel.Click += new System.EventHandler(this.bBlueChannel_Click);
//
// bGreenChannel
//
this.bGreenChannel.Location = new System.Drawing.Point(564, 253);
this.bGreenChannel.Name = "bGreenChannel";
this.bGreenChannel.Size = new System.Drawing.Size(125, 28);
this.bGreenChannel.TabIndex = 17;
this.bGreenChannel.Text = "Green channel";
this.bGreenChannel.UseVisualStyleBackColor = true;
this.bGreenChannel.Click += new System.EventHandler(this.bGreenChannel_Click);
//
// bAllChannels
//
this.bAllChannels.Location = new System.Drawing.Point(563, 321);
this.bAllChannels.Name = "bAllChannels";
this.bAllChannels.Size = new System.Drawing.Size(126, 28);
this.bAllChannels.TabIndex = 18;
this.bAllChannels.Text = "All channels";
this.bAllChannels.UseVisualStyleBackColor = true;
this.bAllChannels.Click += new System.EventHandler(this.bAllChannels_Click);
//
// lSelectFrame
//
this.lSelectFrame.AutoSize = true;
this.lSelectFrame.Location = new System.Drawing.Point(563, 159);
this.lSelectFrame.Name = "lSelectFrame";
this.lSelectFrame.Size = new System.Drawing.Size(86, 16);
this.lSelectFrame.TabIndex = 19;
this.lSelectFrame.Text = "Select frame:";
//
// lImageFormat
//
this.lImageFormat.AutoSize = true;
this.lImageFormat.Location = new System.Drawing.Point(563, 395);
this.lImageFormat.Name = "lImageFormat";
this.lImageFormat.Size = new System.Drawing.Size(92, 16);
this.lImageFormat.TabIndex = 20;
this.lImageFormat.Text = "Image-format:";
//
// bRotate
//
this.bRotate.Location = new System.Drawing.Point(564, 86);
this.bRotate.Name = "bRotate";
this.bRotate.Size = new System.Drawing.Size(125, 28);
this.bRotate.TabIndex = 21;
this.bRotate.Text = "Rotate";
this.bRotate.UseVisualStyleBackColor = true;
this.bRotate.Click += new System.EventHandler(this.bRotate_Click);
//
// vRotate
//
this.vRotate.Location = new System.Drawing.Point(695, 80);
this.vRotate.Maximum = 360;
this.vRotate.Name = "vRotate";
this.vRotate.Size = new System.Drawing.Size(170, 45);
this.vRotate.TabIndex = 22;
this.vRotate.TickFrequency = 10;
this.vRotate.TickStyle = System.Windows.Forms.TickStyle.Both;
this.vRotate.Scroll += new System.EventHandler(this.vRotate_Scroll);
//
// lRotate
//
this.lRotate.AutoSize = true;
this.lRotate.Location = new System.Drawing.Point(871, 92);
this.lRotate.Name = "lRotate";
this.lRotate.Size = new System.Drawing.Size(15, 16);
this.lRotate.TabIndex = 23;
this.lRotate.Text = "0";
//
// lColors
//
this.lColors.AutoSize = true;
this.lColors.Location = new System.Drawing.Point(740, 394);
this.lColors.Name = "lColors";
this.lColors.Size = new System.Drawing.Size(60, 16);
this.lColors.TabIndex = 24;
this.lColors.Text = "Colors: 0";
//
// nShowMetadata
//
this.nShowMetadata.Location = new System.Drawing.Point(696, 15);
this.nShowMetadata.Name = "nShowMetadata";
this.nShowMetadata.Size = new System.Drawing.Size(125, 28);
this.nShowMetadata.TabIndex = 25;
this.nShowMetadata.Text = "Show metadata";
this.nShowMetadata.UseVisualStyleBackColor = true;
this.nShowMetadata.Click += new System.EventHandler(this.nShowMetadata_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(908, 423);
this.Controls.Add(this.nShowMetadata);
this.Controls.Add(this.lColors);
this.Controls.Add(this.lRotate);
this.Controls.Add(this.vRotate);
this.Controls.Add(this.bRotate);
this.Controls.Add(this.lImageFormat);
this.Controls.Add(this.lSelectFrame);
this.Controls.Add(this.bAllChannels);
this.Controls.Add(this.bGreenChannel);
this.Controls.Add(this.bBlueChannel);
this.Controls.Add(this.bRedChannelOnly);
this.Controls.Add(this.vGamma);
this.Controls.Add(this.bAdjustGamma);
this.Controls.Add(this.lComment);
this.Controls.Add(this.cbSelectFrame);
this.Controls.Add(this.bGreyscale);
this.Controls.Add(this.lMetadataCount);
this.Controls.Add(this.lBpp);
this.Controls.Add(this.lHeight);
this.Controls.Add(this.lWidth);
this.Controls.Add(this.bSaveImage);
this.Controls.Add(this.bLoadImage);
this.Controls.Add(this.pictureBox);
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Sample 11";
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.vGamma)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.vRotate)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button bLoadImage;
private System.Windows.Forms.Button bSaveImage;
private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.SaveFileDialog sfd;
private System.Windows.Forms.Label lWidth;
private System.Windows.Forms.Label lHeight;
private System.Windows.Forms.Label lBpp;
private System.Windows.Forms.Label lMetadataCount;
private System.Windows.Forms.Button bGreyscale;
private System.Windows.Forms.ComboBox cbSelectFrame;
private System.Windows.Forms.Label lComment;
private System.Windows.Forms.Button bAdjustGamma;
private System.Windows.Forms.NumericUpDown vGamma;
private System.Windows.Forms.Button bRedChannelOnly;
private System.Windows.Forms.Button bBlueChannel;
private System.Windows.Forms.Button bGreenChannel;
private System.Windows.Forms.Button bAllChannels;
private System.Windows.Forms.Label lSelectFrame;
private System.Windows.Forms.Label lImageFormat;
private System.Windows.Forms.Button bRotate;
private System.Windows.Forms.TrackBar vRotate;
private System.Windows.Forms.Label lRotate;
private System.Windows.Forms.Label lColors;
private System.Windows.Forms.Button nShowMetadata;
}
}

View File

@@ -0,0 +1,412 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using FreeImageAPI;
using FreeImageAPI.Metadata;
using FreeImageAPI.Plugins;
namespace Sample11
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
// Capture messages generated by FreeImage
FreeImageEngine.Message += new OutputMessageFunction(FreeImageEngine_Message);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
static void FreeImageEngine_Message(FREE_IMAGE_FORMAT fif, string message)
{
// Display the message
// FreeImage continues code executing when all
// addes subscribers of 'Message' finished returned.
MessageBox.Show(message, "FreeImage-Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// The FreeImageBitmap this sample will work with.
FreeImageBitmap bitmap = null;
// Replaces the current bitmap with the given one.
private void ReplaceBitmap(FreeImageBitmap newBitmap)
{
// Checks whether the bitmap is usable
if (newBitmap == null || newBitmap.IsDisposed)
{
MessageBox.Show(
"Unexpected error.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
// Check whether the image type of the new bitmap is 'FIT_BITMAP'.
// If not convert to 'FIT_BITMAP'.
if (newBitmap.ImageType != FREE_IMAGE_TYPE.FIT_BITMAP)
{
if (!newBitmap.ConvertType(FREE_IMAGE_TYPE.FIT_BITMAP, true))
{
MessageBox.Show(
"Error converting bitmap to standard type.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
}
// Dispose the old bitmap only in case it exists and
// the old instance is another than the new one.
if ((bitmap != null) && !object.ReferenceEquals(bitmap, newBitmap))
{
bitmap.Dispose();
}
// Dispose the picturebox's bitmap in case it exists.
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
}
// Set the new bitmap.
pictureBox.Image = (Bitmap)(bitmap = newBitmap);
// Update gui.
UpdateBitmapInformations();
UpdateFrameSelection();
}
// Get bitmap properties and display them in the gui.
private void UpdateBitmapInformations()
{
if (Bitmap)
{
// Get width
lWidth.Text = String.Format("Width: {0}", bitmap.Width);
// Get Height
lHeight.Text = String.Format("Height: {0}", bitmap.Height);
// Get color depth
lBpp.Text = String.Format("Bpp: {0}", bitmap.ColorDepth);
// Get number of metadata
ImageMetadata mData = bitmap.Metadata;
mData.HideEmptyModels = true;
int mCnt = 0;
foreach (MetadataModel model in mData.List)
{
mCnt += model.Count;
}
lMetadataCount.Text = String.Format("Metadata: {0}", mCnt);
// Get image comment
lComment.Text = String.Format("Image-comment: {0}", bitmap.Comment != null ? bitmap.Comment : String.Empty);
// Get the number of real colors in the image
lColors.Text = String.Format("Colors: {0}", bitmap.UniqueColors);
}
else
{
// Reset all values
lWidth.Text = String.Format("Width: {0}", 0);
lHeight.Text = String.Format("Height: {0}", 0);
lBpp.Text = String.Format("Bpp: {0}", 0);
lMetadataCount.Text = String.Format("Metadata: {0}", 0);
lComment.Text = String.Format("Image-comment: {0}", String.Empty);
lColors.Text = String.Format("Colors: {0}", 0);
}
}
// Update combobox for frame selection.
private void UpdateFrameSelection()
{
cbSelectFrame.Items.Clear();
if (Bitmap)
{
// Get number of frames in the bitmap
if (bitmap.FrameCount > 1)
{
// Add an entry for each frame to the combobox
for (int i = 0; i < bitmap.FrameCount; i++)
{
cbSelectFrame.Items.Add(String.Format("Frame {0}", i + 1));
}
}
}
}
// Returns true in case the variable 'bitmap'
// is set and not disposed.
private bool Bitmap
{
get { return ((bitmap != null) && (!bitmap.IsDisposed)); }
}
private void bLoadImage_Click(object sender, EventArgs e)
{
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
// Load the file using autodetection
FreeImageBitmap fib = new FreeImageBitmap(ofd.FileName);
// Rescale the image so that it fits the picturebox
// Get the plugin that was used to load the bitmap
FreeImagePlugin plug = PluginRepository.Plugin(fib.ImageFormat);
lImageFormat.Text = String.Format("Image-format: {0}", plug.Format);
// Replace the existing bitmap with the new one
ReplaceBitmap(fib);
}
catch
{
}
}
}
private void bSaveImage_Click(object sender, EventArgs e)
{
if (pictureBox.Image != null)
{
try
{
if (sfd.ShowDialog() == DialogResult.OK)
{
// Save the bitmap using autodetection
using (FreeImageBitmap temp = new FreeImageBitmap(pictureBox.Image))
{
temp.Save(sfd.FileName);
}
}
}
catch
{
}
}
}
private void bRotate_Click(object sender, EventArgs e)
{
if (Bitmap)
{
// Create a temporary rescaled bitmap
using (FreeImageBitmap temp = bitmap.GetScaledInstance(
pictureBox.DisplayRectangle.Width, pictureBox.DisplayRectangle.Height,
FREE_IMAGE_FILTER.FILTER_CATMULLROM))
{
if (temp != null)
{
// Rotate the bitmap
temp.Rotate((double)vRotate.Value);
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
}
// Display the result
pictureBox.Image = (Bitmap)temp;
}
}
}
}
private void bGreyscale_Click(object sender, EventArgs e)
{
if (Bitmap)
{
// Convert the bitmap to 8bpp and greyscale
ReplaceBitmap(bitmap.GetColorConvertedInstance(
FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP |
FREE_IMAGE_COLOR_DEPTH.FICD_FORCE_GREYSCALE));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
if ((cb != null) && (cb.Items.Count > 0))
{
if (Bitmap)
{
try
{
// Switch the selected frame
bitmap.SelectActiveFrame(cb.SelectedIndex);
ReplaceBitmap(bitmap);
}
catch (ArgumentOutOfRangeException)
{
MessageBox.Show("Error changing frame.", "Error");
}
}
}
}
private void bAdjustGamma_Click(object sender, EventArgs e)
{
if (Bitmap)
{
// Adjust the gamma value
bitmap.AdjustGamma((double)vGamma.Value);
ReplaceBitmap(bitmap);
}
}
private void bRedChannelOnly_Click(object sender, EventArgs e)
{
// Mask out green and blue
SetColorChannels(0xFF, 0x00, 0x00);
}
private void bGreenChannel_Click(object sender, EventArgs e)
{
// Mask out red and blue
SetColorChannels(0x00, 0xFF, 0x00);
}
private void bBlueChannel_Click(object sender, EventArgs e)
{
// Mask out red and green
SetColorChannels(0x00, 0x00, 0xFF);
}
private void bAllChannels_Click(object sender, EventArgs e)
{
if (Bitmap)
{
// Restore the bitmap using the original
ReplaceBitmap(bitmap);
}
}
private void SetColorChannels(int redmask, int greenmask, int bluemask)
{
if (Bitmap)
{
// Create a temporary clone.
using (FreeImageBitmap bitmap = (FreeImageBitmap)this.bitmap.Clone())
{
if (bitmap != null)
{
// Check whether the bitmap has a palette
if (bitmap.HasPalette)
{
// Use the Palette class to handle the bitmap's
// palette. A palette always consist of RGBQUADs.
Palette palette = bitmap.Palette;
// Apply the new values for all three color components.
for (int i = 0; i < palette.Length; i++)
{
RGBQUAD rgbq = palette[i];
rgbq.rgbRed = (byte)(rgbq.rgbRed & redmask);
rgbq.rgbGreen = (byte)(rgbq.rgbGreen & greenmask);
rgbq.rgbBlue = (byte)(rgbq.rgbBlue & bluemask);
palette[i] = rgbq;
}
}
// In case the bitmap has no palette it must have a color depth
// of 16, 24 or 32. Each color depth needs a different wrapping
// structure for the bitmaps data. These structures can be accessed
// by using the foreach clause.
else if (bitmap.ColorDepth == 16)
{
// Iterate over each scanline
// For 16bpp use either Scanline<FI16RGB555> or Scanline<FI16RGB565>
if (bitmap.IsRGB555)
{
foreach (Scanline<FI16RGB555> scanline in bitmap)
{
for (int x = 0; x < scanline.Length; x++)
{
FI16RGB555 pixel = scanline[x];
pixel.Red = (byte)(pixel.Red & redmask);
pixel.Green = (byte)(pixel.Green & greenmask);
pixel.Blue = (byte)(pixel.Blue & bluemask);
scanline[x] = pixel;
}
}
}
else if (bitmap.IsRGB565)
{
foreach (Scanline<FI16RGB565> scanline in bitmap)
{
for (int x = 0; x < scanline.Length; x++)
{
FI16RGB565 pixel = scanline[x];
pixel.Red = (byte)(pixel.Red & redmask);
pixel.Green = (byte)(pixel.Green & greenmask);
pixel.Blue = (byte)(pixel.Blue & bluemask);
scanline[x] = pixel;
}
}
}
}
else if (bitmap.ColorDepth == 24)
{
// Iterate over each scanline
// For 24bpp Scanline<RGBTRIPLE> must be used
foreach (Scanline<RGBTRIPLE> scanline in bitmap)
{
for (int x = 0; x < scanline.Length; x++)
{
RGBTRIPLE pixel = scanline[x];
pixel.rgbtRed = (byte)(pixel.rgbtRed & redmask);
pixel.rgbtGreen = (byte)(pixel.rgbtGreen & greenmask);
pixel.rgbtBlue = (byte)(pixel.rgbtBlue & bluemask);
scanline[x] = pixel;
}
}
}
else if (bitmap.ColorDepth == 32)
{
// Iterate over each scanline
// For 32bpp Scanline<RGBQUAD> must be used
foreach (Scanline<RGBQUAD> scanline in bitmap)
{
for (int x = 0; x < scanline.Length; x++)
{
RGBQUAD pixel = scanline[x];
pixel.rgbRed = (byte)(pixel.rgbRed & redmask);
pixel.rgbGreen = (byte)(pixel.rgbGreen & greenmask);
pixel.rgbBlue = (byte)(pixel.rgbBlue & bluemask);
scanline[x] = pixel;
}
}
}
// Dispose only the picturebox's bitmap
if (pictureBox.Image != null)
{
pictureBox.Image.Dispose();
}
pictureBox.Image = (Bitmap)bitmap;
}
}
}
}
private void vRotate_Scroll(object sender, EventArgs e)
{
TrackBar bar = sender as TrackBar;
if (bar != null)
{
lRotate.Text = bar.Value.ToString();
}
}
private void nShowMetadata_Click(object sender, EventArgs e)
{
if (Bitmap)
{
MetaDataFrame mFrame = new MetaDataFrame();
mFrame.Tag = bitmap.Metadata;
mFrame.ShowDialog(this);
}
}
}
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ofd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="sfd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>84, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,63 @@
namespace Sample11
{
partial class MetaDataFrame
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.tvMetadata = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// tvMetadata
//
this.tvMetadata.Location = new System.Drawing.Point(12, 12);
this.tvMetadata.Name = "tvMetadata";
this.tvMetadata.Size = new System.Drawing.Size(389, 318);
this.tvMetadata.TabIndex = 3;
//
// MetaDataFrame
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(417, 349);
this.Controls.Add(this.tvMetadata);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MetaDataFrame";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Metadata";
this.Load += new System.EventHandler(this.MetaDataFrame_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TreeView tvMetadata;
}
}

View File

@@ -0,0 +1,49 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
using FreeImageAPI;
using FreeImageAPI.Metadata;
namespace Sample11
{
public partial class MetaDataFrame : Form
{
public MetaDataFrame()
{
InitializeComponent();
}
private void MetaDataFrame_Load(object sender, EventArgs e)
{
ImageMetadata iMetadata = this.Tag as ImageMetadata;
if (iMetadata != null)
{
bool backup = iMetadata.HideEmptyModels;
iMetadata.HideEmptyModels = false;
try
{
// Get each metadata model
foreach (MetadataModel metadataModel in iMetadata)
{
// Create a new node for each model
TreeNode modelNode = tvMetadata.Nodes.Add(metadataModel.ToString());
// Get each metadata tag and create a subnode for it
foreach (MetadataTag metadataTag in metadataModel)
{
modelNode.Nodes.Add(metadataTag.Key + ": " + metadataTag.ToString());
}
}
}
// Display error message
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
MessageBox.Show(ex.ToString(), "Exception caught");
}
iMetadata.HideEmptyModels = backup;
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("219019e1-9a57-46c7-b9d7-3928a9277fd6")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,113 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{996068CD-D07A-42E0-856F-ACC71E8565EF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample11</RootNamespace>
<AssemblyName>Sample11</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>none</ErrorReport>
<WarningLevel>4</WarningLevel>
<FileAlignment>512</FileAlignment>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>none</ErrorReport>
<WarningLevel>4</WarningLevel>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<FileAlignment>512</FileAlignment>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>none</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<FileAlignment>512</FileAlignment>
<DebugType>
</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>none</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<FileAlignment>512</FileAlignment>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>none</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<FileAlignment>512</FileAlignment>
<DebugType>
</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>none</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="FreeImageNET, Version=3.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Bin\FreeImageNET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="MetaDataFrame.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MetaDataFrame.Designer.cs">
<DependentUpon>MetaDataFrame.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<SubType>Designer</SubType>
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MetaDataFrame.resx">
<SubType>Designer</SubType>
<DependentUpon>MetaDataFrame.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,114 @@
What's New for FreeImage.NET
* : fixed
- : removed
! : changed
+ : added
December 21, 2009 - 3.13.1.1
* [Carsten Klein] Fixed a threading bug in OpenMultiBitmapFromStream and CloseMultiBitmap. Access to the streamHandles Dictionary is now thread safe.
September 15, 2009 - 3.13.0.1
+ [Jean-Philippe Goerke] Added PFM, PICT and RAW file formats.
+ [Jean-Philippe Goerke] Added loading flag JPEG_EXIFROTATE.
+ [Jean-Philippe Goerke] Added method GetNativeVersion() to the FreeImage class.
! [Jean-Philippe Goerke] Changed FreeImage.IsAvailable() now returning false in case the native library is out of date or unusable.
- [Jean-Philippe Goerke] Removed FREEIMAGE_MAJOR_VERSION, FREEIMAGE_MINOR_VERSION and FREEIMAGE_RELEASE_SERIAL constants from class FreeImage.
+ [Jean-Philippe Goerke] Added enumeration FREE_IMAGE_COLOR_OPTIONS.
+ [Jean-Philippe Goerke] Added new overloads for FreeImage.Allocate() and FreeImage.AllocateT().
+ [Jean-Philippe Goerke] Added methods AllocateEx(), AllocateExT(), FillBackground() and EnlargeCanvas() to class FreeImage.
+ [Jean-Philippe Goerke] Added methods FillBackground(), EnlargeCanvas() and GetEnlargedInstance() to class FreeImageBitmap.
- [Jean-Philippe Goerke] Removed unused ConvertLineXtoY() methods.
* [kruno13] Fixed a bug in the FreeImageBitmap constructors.
- [Jean-Philippe Goerke] Removed unneeded GCHandles used with delegates.
+ [Jean-Philippe Goerke] Added overloaded method OpenMultiBitmapFromStream to class FreeImage.
+ [Jean-Philippe Goerke] FreeImageBitmap now supports loading multipage bitmaps from streams. Warning: The stream must remain open for the bitmap's lifetime.
* [mshanke] Fixed some IPTC metadata incorrect namings.
! [Jean-Philippe Goerke] Method FreeImage.RotateClassic is now deprecated.
+ [Jean-Philippe Goerke] Added method Rotate() to the FreeImage class.
! [Jean-Philippe Goerke] FreeImageBitmap now uses the method Rotate instead of RotateClassic.
April 20, 2009 - 1.10
! [Jean-Philippe Goerke] Updated wrapper-version to 1.10 including some minor changes.
February 27, 2009 - 1.09
+ [Jean-Philippe Goerke] Help file creation now uses the Version Builder plugin of Sandcastle Help File Builder to generate an MSDN-like Version Information paragraph in the help file.
+ [Jean-Philippe Goerke] Added new metadata model class MDM_EXIF_MAIN to replace MDM_MAIN. Class MDM_MAIN still exists but is marked obsolete and will be removed in a future release.
+ [Jean-Philippe Goerke] Added various properties to access the value of metadata tags directly to all MDM_* classes expect MDM_CUSTOM, MDM_NODATA and MDM_MAKERNOTE.
! [Jean-Philippe Goerke] Now classes deriving from MetadataModel, expect obsoltete class MDM_MAIN, are no longer sealed.
! [Jean-Philippe Goerke] Class GifInformation now derives from MDM_ANIMATION. Moved properties into base class MDM_ANIMATION.
+ [Jean-Philippe Goerke] Added enumerations AltitudeType, DirectionReference, InteroperabilityMode, LatitudeType, LongitudeType, ImageOrientation and VelocityUnit to class MetadataModel.
* [Jean-Philippe Goerke] Fixed a bug in MetadataTag.Count, MetadataTag.Length and MetadataTag.Value.
+ [Jean-Philippe Goerke] Added attribute DebuggerBrowsable(DebuggerBrowsableState.Never) to some protected and private fields.
February 23, 2009 - 1.08
! [Jean-Philippe Goerke] FreeImage.NET now uses Sandcastle Help File Builder 1.8.0.1
+ [Jean-Philippe Goerke] Added new Sandcastle Help File Builder project file FreeImage.NET.shfbproj.
* [headkaze] Fixed a bug in FreeImage.CreateFromBitmap, which now incorporates any transparency information from palletized .NET Bitmaps.
+ [Jean-Philippe Goerke] Added new overloaded method CreateGlobalPalette() to class GifInformation to create global palettes from local palettes.
! [Jean-Philippe Goerke] Renamed internal method FreeImage.SetTransparencyTable_ to FreeImage.SetTransparencyTable.
+ [Jean-Philippe Goerke] Added attribute DebuggerBrowsable(DebuggerBrowsableState.Never) to many protected and private fields.
February 20, 2009 - 1.07
* [Jean-Philippe Goerke] Fixed a bug in FreeImage.IsFilenameValidForFIF and FreeImage.IsExtensionValidForFIF.
* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveEx that could prevent saving supported non-bitmap types.
* [Jean-Philippe Goerke] Fixed a small bug in FreeImage.CompareData.
+ [Jean-Philippe Goerke] Added two overloads of ColorQuantizeEx() in class FreeImage to return images with a color depth smaller than 8.
! [Jean-Philippe Goerke] Updated FreeImage.ConvertColorDepth to support 1- and 4-bpp color conversions (FreeImage_ConvertTo4Bits only creates grayscale results).
* [headkaze] Fixed a bug in FreeImage.GetBitmap, which now adds any transparency information to palletized .NET Bitmaps.
* [headkaze] Fixed a bug in FreeImage.GetBitmap and FreeImage.CreateFromBitmap to support palettes with sizes different from 2, 16 and 256 entries.
! [Jean-Philippe Goerke] Improved handling of multipage bitmaps in FreeImageBitmap class.
+ [Jean-Philippe Goerke] Added new overloads for FreeImageBitmap.SaveAdd() to allow inserting frames at a specified page index.
+ [Jean-Philippe Goerke] Added new class GifInformation which provides access to GIF format specific metadata (GlobalPalette, Animation, etc.).
+ [Jean-Philippe Goerke] Added enumeration DisposalMethodType.
! [Jean-Philippe Goerke] Updated class MemoryArray<T>, which now is Disposable and has a new static constructor.
! [Jean-Philippe Goerke] Removed code using reflection from class ImageMetadata.
+ [Jean-Philippe Goerke] Added new ctor(FITAG) and ctor(MetadataTag) to class Palette to support palettes stored in metadata tags.
+ [Jean-Philippe Goerke] Added new ctor(RGBQUAD[]), ctor(Color[]) and ctor(int) to create new stand-alone palettes to class Palette.
+ [Jean-Philippe Goerke] Added overloaded CreateGrayscalePalette(), Reverse() and CopyFrom() to class Palette.
! [Jean-Philippe Goerke] Changed the behavior of MetadataTag.Value. byte and byte[] are now stored as FREE_IMAGE_MDTYPE.FIDT_BYTE instead of FREE_IMAGE_MDTYPE.FIDT_UNDEFINED.
+ [Jean-Philippe Goerke] Added a type check to MetadataTag.SetValue(object), MetadataTag.SetValue(object, FREE_IMAGE_MDTYPE) and the setter of MetadataTag.Value.
November 18, 2008 - 1.06
* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveEx.
! [Jean-Philippe Goerke] Improved method FreeImage.IsFilenameValidForFIF.
November 5, 2008 - 1.05
! [Jean-Philippe Goerke] Updated documentation of FreeImage.ConvertFromRawBits and FreeImage.ConvertToRawBits.
+ [Jean-Philippe Goerke] Added new overload ConvertFromRawBits(byte[],int,int,int,uint,uint,uint,uint,bool) to the FreeImage class.
+ [Jean-Philippe Goerke] Added new overload ConvertFromRawBits(byte[],FREE_IMAGE_TYPE,int,int,int,uint,uint,uint,uint bool) to the FreeImage class.
+ [Jean-Philippe Goerke] Added new overload ConvertToRawBits(byte[],FIBITMAP,int,uint,uint,uint,uint,bool) to the FreeImage class.
! [Jean-Philippe Goerke] Improved method FreeImage.CreatePropertyItem.
+ [Jean-Philippe Goerke] Added overloads for CopyMemory to class FreeImage which support direct usage of arrays.
! [Jean-Philippe Goerke] Replaced calls to FreeImage.MoveMemory with FreeImage.CopyMemory.
! [Jean-Philippe Goerke] Class FreeImageBitmap now derives from MarshalByRefObject.
+ [Jean-Philippe Goerke] Added new ctor(int,int,int,PixelFormat,byte[]) and ctor(int,int,int,int,FREE_IMAGE_TYPE,byte[]) to the FreeImageBitmap class.
August 29, 2008 - 1.04
+ [Jean-Philippe Goerke] Added new target architectures x86 and x64 to the Visual Studio 2005 solution and project files.
+ [Jean-Philippe Goerke] Added static readonly field Zero to FIBITMAP, FIMEMORY, FIMETADATA, FIMULTIBITMAP and FITAG.
! [Jean-Philippe Goerke] Changed CreateFromBitmap to handle all formats contained by System.Drawing.Imaging.PixelFormat.
+ [Jean-Philippe Goerke] Added overload for ConvertFromRawBits to class FreeImage which supports creating images of any FREE_IMAGE_TYPE from raw bits.
+ [Jean-Philippe Goerke] Added method GetTypeParameters to class FreeImage.
! [Jean-Philippe Goerke] Both constructors FreeImageBitmap.ctor(int,int,PixelFormat) and FreeImageBitmap.ctor(int,int,int,PixelFormat,IntPtr) now work with all formats defined in PixelFormat.
+ [Jean-Philippe Goerke] Added new constructor FreeImageBitmap.ctor(int,int,int,int,FREE_IMAGE_TYPE,IntPtr) to FreeImageBitmap class.
August 18, 2008 - 1.03
* [Eric T. Wilson] Added GC.AddMemoryPressure and GC.RemoveMemoryPressure to FreeImageBitmap class.
+ [Eric T. Wilson] Added ToBitmap method to FreeImageBitmap class.
! [Eric T. Wilson] Changed implicit conversion operators to and from System.Drawing.Bitmap to explicit operators.
- [Eric T. Wilson] Removed Message event from FreeImage class. Use event FreeImageEngine.Message instead.
- [Eric T. Wilson] Removed contructors ctor(int) and ctor(IntPtr) from FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG.
- [Eric T. Wilson] Removed implicit conversion operators from and to int and IntPtr from FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG.
+ [Jean-Philippe Goerke] Added SetNull method to FIBITMAP, FIMULTIBITMAP, FIMEMORY, FIMETADATA and FITAG.
! [Jean-Philippe Goerke] Changed handling of multipage images in FreeImageBitmap: As with System.Drawing.Bitmap, any changes applied to an active frame are no longer written back to the multipage image loaded.
* [Jean-Philippe Goerke] Fixed a bug in FreeImage.SaveToStream(ref FIBITMAP, Stream, FREE_IMAGE_FORMAT, FREE_IMAGE_SAVE_FLAGS, FREE_IMAGE_COLOR_DEPTH, bool): changed catch block into a finally block.
July 25, 2008 - 1.02
+ [Jean-Philippe Goerke] Improved handling of XMP metadata in MetadataTag.cs: Key is now set to "XMLPacket" not changeable if Model is FREE_IMAGE_MDMODEL.FIMD_XMP.
July 01, 2008 - 1.01
+ [Jean-Philippe Goerke] Added methods Quantize and GetQuantizedInstance to the FreeImageBitmap class.
November 12, 2007 - 1.00
+ [Jean-Philippe Goerke] Initial release.