2
using System.Diagnostics;
5
namespace FreeImageAPI.Metadata
8
/// Provides additional information specific for GIF files. This class cannot be inherited.
10
public class GifInformation : MDM_ANIMATION
13
/// Initializes a new instance of the <see cref="GifInformation"/> class
14
/// with the specified <see cref="FreeImageBitmap"/>.
16
/// <param name="bitmap">A reference to a <see cref="FreeImageBitmap"/> instance.</param>
17
public GifInformation(FreeImageBitmap bitmap)
23
/// Gets or sets a value indicating whether this frame uses the
24
/// GIF image's global palette. If set to <b>false</b>, this
25
/// frame uses its local palette.
28
/// <b>Handling of null values</b><para/>
29
/// A null value indicates, that the corresponding metadata tag is not
30
/// present in the metadata model.
31
/// Setting this property's value to a non-null reference creates the
32
/// metadata tag if necessary.
33
/// Setting this property's value to a null reference deletes the
34
/// metadata tag from the metadata model.
36
public bool? UseGlobalPalette
40
byte? useGlobalPalette = GetTagValue<byte>("NoLocalPalette");
41
return useGlobalPalette.HasValue ? (useGlobalPalette.Value != 0) : default(bool?);
48
val = (byte)(value.Value ? 1 : 0);
50
SetTagValue("NoLocalPalette", val);
55
/// Creates a global palette for the GIF image, intialized with all entries of the
56
/// current local palette.
57
/// The property <see cref="UseGlobalPalette"/> will be set to <b>true</b> when
58
/// invoking this method. This effectively enables the newly created global palette.
60
/// <exception cref="InvalidOperationException">
61
/// The image does not have a palette.
63
public void CreateGlobalPalette()
65
CreateGlobalPalette(new Palette(dib));
69
/// Creates a global palette for the GIF image with the specified size, intialized
70
/// with the first <paramref name="size"/> entries of the current local palette.
71
/// The property <see cref="UseGlobalPalette"/> will be set to <b>true</b> when
72
/// invoking this method. This effectively enables the newly created global palette.
74
/// <param name="size">The size of the newly created global palette.</param>
75
/// <exception cref="ArgumentNullException">
76
/// <paramref name="palette"/> is a null reference.</exception>
77
public void CreateGlobalPalette(int size)
79
CreateGlobalPalette(new Palette(dib), size);
83
/// Creates a global palette for the GIF image, intialized with the entries
84
/// of the specified palette.
85
/// The property <see cref="UseGlobalPalette"/> will be set to <b>true</b> when
86
/// invoking this method. This effectively enables the newly created global palette.
88
/// <param name="palette">The palette that contains the initial values for
89
/// the newly created global palette.</param>
90
/// <exception cref="ArgumentNullException">
91
/// <paramref name="palette"/> is a null reference.</exception>
92
public void CreateGlobalPalette(Palette palette)
96
throw new ArgumentNullException("palette");
99
GlobalPalette = palette;
100
UseGlobalPalette = true;
104
/// Creates a global palette for the GIF image with the specified size, intialized
105
/// with the first <paramref name="size"/> entries of the specified palette.
106
/// The property <see cref="UseGlobalPalette"/> will be set to <b>true</b> when
107
/// invoking this method. This effectively enables the newly created global palette.
109
/// <param name="palette">The palette that contains the initial values for
110
/// the newly created global palette.</param>
111
/// <param name="size">The size of the newly created global palette.</param>
112
/// <exception cref="ArgumentNullException">
113
/// <paramref name="palette"/> is a null reference.</exception>
114
public void CreateGlobalPalette(Palette palette, int size)
118
throw new ArgumentNullException("palette");
122
throw new ArgumentOutOfRangeException("size");
125
Palette pal = new Palette(size);
126
pal.CopyFrom(palette);
127
GlobalPalette = palette;
128
UseGlobalPalette = true;
b'\\ No newline at end of file'