Click here to Skip to main content
15,886,071 members
Articles / Multimedia / GDI+
Article

Fireball.Core FreeImage Wrapper

Rate me:
Please Sign up or sign in to vote.
2.29/5 (3 votes)
4 Jan 20062 min read 49.9K   1.6K   29   7
Discover the Fireball.Core FreeImage wrapper for C#.

Free Image Demo Example

Introduction

Fireball.Core is class library developed with C#, with the objective to integrate an API that I need for my daily work, and as a base for my other open source libraries. In this article, I can only describe the FreeImage class, but on the Fireball.Core library there are some other classes presented as well.

Background

FreeImage is the best open source class library for manipulating images. To get the Fireball.Core library working, you need to download it from SourceForge. The binary version for Windows is to be downloaded and put on C:\Windows\System32. I also provide here a little example project, for showing how simple it is to use it, but the example is incomplete and the wrapper needs more work.

Using the code

Using the FreeImage wrapper is very simple, you need only to reference the Fireball.Core.dll on your project and add an using directive and instanciate the class with a filename.

C#
using System;
using System.Drawing;

public class test
{
    ....

    FreeImage _fi = null;

    public void LoadImage(string filename)
    {
        _fi = new FreeImage(filename);
    }
}

Now, you have the image file loaded. On that image, you can apply a rotation, a brightness change or contrast. See the example that applies a rotation, here:

C#
public void Rotate(double angle)
{
    _fi.Rotate(angle);
}

Example: if you call test.Rotate(25); you have applied to your image a left rotation of 25 degrees!!

For a more detailed class view, see this image exported from the Visual Studio class diagram.

Now, for applying some effects, I am implementing a FreeImageTrasformation class that is a base class for all transformation classes, like FreeImageRescale. For example, you have a 1240 x 1200 image, and you need to rescale it to 800 x 600; you can do that simply with two lines of code:

C#
FreeImageRescale rscTransform = new FreeImageRescale(800, 600);
_FreeImage.ApplyTransformation(rscTransform);

That is all for now! I don't have more time for writing. FreeImage is also the best when you need to manipulate big images, because the Bitmap class of the .NET framework doesn't support big images. If you are interested to contribute to this project, you can join the Fireball community by simply registering on the Fireball forums. On my website, you can find nightly builds on the download section. All code are under the terms of the LGPL license that gives you the possibility to link the library on to your commercial projects without the need to redistribute your code! You only need to enclose a lgpl.txt file on the same directory where the Fireball.Core library is located, with a link to my website. Any reference on your About message is very much appreciated ;)

Points of Interest

Please contribute to the Fireball project!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThanks Pin
Hamid Attari14-May-08 10:04
Hamid Attari14-May-08 10:04 
GeneralWhen I save a big Image [modified] Pin
Jm2f25-Oct-06 23:56
Jm2f25-Oct-06 23:56 
GeneralHDR images Pin
image_processor11-Jul-06 3:05
image_processor11-Jul-06 3:05 
GeneralRotate Working Pin
Reanalyse10-Jan-06 15:47
Reanalyse10-Jan-06 15:47 
GeneralRe: Rotate Working Pin
dotnetfireball15-Jan-06 8:27
dotnetfireball15-Jan-06 8:27 
GeneralRe: Rotate Working Pin
Reanalyse15-Jan-06 20:51
Reanalyse15-Jan-06 20:51 
GeneralRe: Rotate Working Pin
Sander van Driel2-Mar-06 3:49
Sander van Driel2-Mar-06 3:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.