/
Font.GlyphIndexer.cs
58 lines (53 loc) · 1.78 KB
/
Font.GlyphIndexer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Idmr.LfdReader.dll, Library file to read and write LFD resource files
* Copyright (C) 2009-2021 Michael Gaisser (mjgaisser@gmail.com)
* Licensed under the MPL v2.0 or later
*
* Full notice in help/Idmr.LfdReader.chm
* Version: 1.2
*/
/* CHANGE LOG
* v1.2, 160712
* [ADD] _isModified edits
* v1.1, 141215
* [UPD] changed license to MPL
* v1.0
*/
using Idmr.Common;
using System;
using System.Drawing;
namespace Idmr.LfdReader
{
public partial class Font : Resource
{
/// <summary>Object to provide array access to the character glyphs.</summary>
public class GlyphIndexer : Indexer<Bitmap>
{
readonly Font _parent;
/// <summary>Initializes the indexer.</summary>
/// <param name="parent">The parent resource.</param>
internal GlyphIndexer(Font parent)
{
_parent = parent;
_items = parent._glyphs;
}
/// <summary>Gets or sets the individual images.</summary>
/// <param name="index">Array index.</param>
/// <returns><see cref="System.Drawing.Imaging.PixelFormat.Format1bppIndexed"/> Bitmap.</returns>
/// <exception cref="ArgumentException">Image Height is incorrect.</exception>
/// <exception cref="BoundaryException">Maximum character width is exceeded.</exception>
/// <exception cref="IndexOutOfRangeException">Invalid <i>index</i> value.</exception>
public override Bitmap this[int index]
{
get { return _items[index]; }
set
{
if (value.Height != _parent._height) throw new ArgumentException("New image not required height (" + _parent._height + "px)", "value");
if (value.Width > _parent._bitsPerScanLine) throw new BoundaryException("value.Width", _parent._bitsPerScanLine.ToString());
_items[index] = GraphicsFunctions.ConvertTo1bpp(value);
_parent._isModifed = true;
}
}
}
}
}