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