本文整理汇总了C#中BITMAPINFO.init方法的典型用法代码示例。如果您正苦于以下问题:C# BITMAPINFO.init方法的具体用法?C# BITMAPINFO.init怎么用?C# BITMAPINFO.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BITMAPINFO
的用法示例。
在下文中一共展示了BITMAPINFO.init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBuffer
/// <summary>
/// Creates a new <see cref="NativeBuffer"/> with the given dimensions.
/// </summary>
/// <param name="buffer">The storage location for the buffer object.</param>
/// <param name="w">The width.</param>
/// <param name="h">The height.</param>
/// <param name="isDIB">True if the buffer should be DIB backed, false for Marshal.</param>
/// <returns>Returns the data buffer.</returns>
public static ARGB* CreateBuffer(out NativeBuffer buffer, int w, int h, bool isDIB)
{
ARGB* pixels;
IntPtr handle;
DeviceContext context = null;
if(isDIB)
{
context = new DeviceContext();
//create info
BITMAPINFO info = new BITMAPINFO();
//init with size
info.init(w, h);
//create DIB
handle = CreateDIBSection(context.Handle, ref info, DIB_RGB_COLORS, out pixels, IntPtr.Zero, 0);
WinAPIUtils.Assert(handle != IntPtr.Zero);
//select the DIB into the DC
context.Push(handle);
}else
{
handle = Marshal.AllocHGlobal(w * h * 4);
pixels = (ARGB*)handle;
}
//create buffer wrapper
buffer = new NativeBuffer{isDIB = isDIB, Handle = handle, Context = context};
//return the data
return pixels;
}