import
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")]
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user