Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Scanline.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Runtime.InteropServices;
5 
6 namespace FreeImageAPI
7 {
8  /// <summary>
9  /// Provides methods for working with generic bitmap scanlines.
10  /// </summary>
11  /// <typeparam name="T">Type of the bitmaps' scanlines.</typeparam>
12  public sealed class Scanline<T> : MemoryArray<T> where T : struct
13  {
14  /// <summary>
15  /// Initializes a new instance based on the specified FreeImage bitmap.
16  /// </summary>
17  /// <param name="dib">Handle to a FreeImage bitmap.</param>
18  public Scanline(FIBITMAP dib)
19  : this(dib, 0)
20  {
21  }
22 
23  /// <summary>
24  /// Initializes a new instance based on the specified FreeImage bitmap.
25  /// </summary>
26  /// <param name="dib">Handle to a FreeImage bitmap.</param>
27  /// <param name="scanline">Index of the zero based scanline.</param>
28  public Scanline(FIBITMAP dib, int scanline)
29  : this(dib, scanline, (int)(typeof(T) == typeof(FI1BIT) ?
30  FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) :
31  typeof(T) == typeof(FI4BIT) ?
32  FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib) / 4 :
33  (FreeImage.GetBPP(dib) * FreeImage.GetWidth(dib)) / (Marshal.SizeOf(typeof(T)) * 8)))
34  {
35  }
36 
37  internal Scanline(FIBITMAP dib, int scanline, int length)
38  : base(FreeImage.GetScanLine(dib, scanline), length)
39  {
40  if (dib.IsNull)
41  {
42  throw new ArgumentNullException("dib");
43  }
44  if ((scanline < 0) || (scanline >= FreeImage.GetHeight(dib)))
45  {
46  throw new ArgumentOutOfRangeException("scanline");
47  }
48  }
49  }
50 }
The FIBITMAP structure is a handle to a FreeImage bimtap.
Definition: FIBITMAP.cs:50
Scanline(FIBITMAP dib, int scanline)
Initializes a new instance based on the specified FreeImage bitmap.
Definition: Scanline.cs:28
The FI1BIT structure represents a single bit. It's value can be 0 or 1.
Definition: FI1BIT.cs:14
bool IsNull
Gets whether the handle is a null or not.
Definition: FIBITMAP.cs:91
Scanline(FIBITMAP dib)
Initializes a new instance based on the specified FreeImage bitmap.
Definition: Scanline.cs:18
The FI4BIT structure represents the half of a Byte. It's valuerange is between 0 and 15...
Definition: FI4BIT.cs:14