本文整理汇总了C#中BITMAPINFO.Init方法的典型用法代码示例。如果您正苦于以下问题:C# BITMAPINFO.Init方法的具体用法?C# BITMAPINFO.Init怎么用?C# BITMAPINFO.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BITMAPINFO
的用法示例。
在下文中一共展示了BITMAPINFO.Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resize
/// <summary>
/// Resizes the section.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="bitCount">The bit count.</param>
public void Resize(int width, int height, int bitCount)
{
// Destroy existing objects.
Destroy();
// Set parameters.
Width = width;
Height = height;
// Create a bitmap info structure.
BITMAPINFO info = new BITMAPINFO();
info.Init();
// Set the data.
info.biBitCount = (short)bitCount;
info.biPlanes = 1;
info.biWidth = width;
info.biHeight = height;
// Create the bitmap.
HBitmap = Win32.CreateDIBSection(parentDC, ref info, Win32.DIB_RGB_COLORS,
out bits, IntPtr.Zero, 0);
Win32.SelectObject(parentDC, HBitmap);
}
示例2: Create
/// <summary>
/// Creates the specified width.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="bitCount">The bit count.</param>
/// <returns></returns>
public virtual bool Create(IntPtr hDC, int width, int height, int bitCount)
{
this.Width = width;
this.Height = height;
parentDC = hDC;
// Destroy existing objects.
Destroy();
// Create a bitmap info structure.
BITMAPINFO info = new BITMAPINFO();
info.Init();
// Set the data.
info.biBitCount = (short)bitCount;
info.biPlanes = 1;
info.biWidth = width;
info.biHeight = height;
// Create the bitmap.
HBitmap = Win32.CreateDIBSection(hDC, ref info, Win32.DIB_RGB_COLORS,
out bits, IntPtr.Zero, 0);
Win32.SelectObject(hDC, HBitmap);
// Set the OpenGL pixel format.
SetPixelFormat(hDC, bitCount);
return true;
}