Click here to Skip to main content
Click here to Skip to main content

Fireball.Core FreeImage Wrapper

, 4 Jan 2006
Rate this:
Please Sign up or sign in to vote.
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.

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:

    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:

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 Wink | ;)

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

Share

About the Author

dotnetfireball
Web Developer
Italy Italy
No Biography provided

Comments and Discussions

 
GeneralThanks PinmemberHamid Attari14-May-08 11:04 
GeneralWhen I save a big Image [modified] PinmemberJm2f26-Oct-06 0:56 
GeneralHDR images Pinmemberimage_processor11-Jul-06 4:05 
GeneralRotate Working PinmemberReanalyse10-Jan-06 16:47 
GeneralRe: Rotate Working Pinmemberdotnetfireball15-Jan-06 9:27 
GeneralRe: Rotate Working PinmemberReanalyse15-Jan-06 21:51 
GeneralRe: Rotate Working PinmemberSander van Driel2-Mar-06 4:49 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150327.1 | Last Updated 4 Jan 2006
Article Copyright 2006 by dotnetfireball
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid