~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Wrapper/FreeImage.NET/cs/Samples/Sample 07 - ICC Profiles/Program.cs

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using FreeImageAPI;
 
4
 
 
5
namespace Sample07
 
6
{
 
7
        class Program
 
8
        {
 
9
                static void Main(string[] args)
 
10
                {
 
11
                        // Check if FreeImage.dll is available (can be in %path%).
 
12
                        if (!FreeImage.IsAvailable())
 
13
                        {
 
14
                                Console.WriteLine("FreeImage.dll seems to be missing. Aborting.");
 
15
                                return;
 
16
                        }
 
17
 
 
18
                        Sample sample = new Sample();
 
19
                        // This example shows how to work with ICC-Profiles.
 
20
                        sample.Example();
 
21
                }
 
22
        }
 
23
 
 
24
        public class Sample
 
25
        {
 
26
                public void Example()
 
27
                {
 
28
                        // Load the sample bitmap.
 
29
                        FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");
 
30
 
 
31
                        // Check success
 
32
                        if (dib.IsNull)
 
33
                        {
 
34
                                Console.WriteLine("Sample.jpg could not be loaded. Aborting.");
 
35
                                return;
 
36
                        }
 
37
 
 
38
                        // Get the bitmaps ICC-Profile.
 
39
                        FIICCPROFILE icc = FreeImage.GetICCProfileEx(dib);
 
40
 
 
41
                        // Print the profiles address.
 
42
                        Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
 
43
 
 
44
                        // Print the profiles size
 
45
                        Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
 
46
 
 
47
                        // Create data for a new profile.
 
48
                        byte[] data = new byte[256];
 
49
                        for (int i = 0; i < data.Length; i++)
 
50
                                data[i] = (byte)i;
 
51
 
 
52
                        // Create the new profile
 
53
                        icc = new FIICCPROFILE(dib, data);
 
54
 
 
55
                        Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
 
56
                        Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
 
57
 
 
58
                        // Create the new profile but only use the first 64 bytes
 
59
                        icc = new FIICCPROFILE(dib, data, 64);
 
60
 
 
61
                        Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
 
62
                        Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
 
63
 
 
64
                        // CreateICCProfileEx(...) does the same as above
 
65
                        icc = FreeImage.CreateICCProfileEx(dib, data, 16);
 
66
 
 
67
                        Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
 
68
                        Console.WriteLine("The profiles size is : {0} bytes", icc.Size);
 
69
 
 
70
                        FreeImage.UnloadEx(ref dib);
 
71
                }
 
72
        }
 
73
}