本文整理汇总了C#中BITMAPINFO类的典型用法代码示例。如果您正苦于以下问题:C# BITMAPINFO类的具体用法?C# BITMAPINFO怎么用?C# BITMAPINFO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BITMAPINFO类属于命名空间,在下文中一共展示了BITMAPINFO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jonhartnett,项目名称:IROM-Util,代码行数:35,代码来源:NativeBuffer.cs
示例2: Create24bppDIBSection
public static IntPtr Create24bppDIBSection(int nWidth, int nHeight)
{
BITMAPINFO bmi = new BITMAPINFO(nWidth, nHeight, 24);
IntPtr pBits;
return CreateDIBSection(IntPtr.Zero, bmi, DIB_RGB_COLORS, out pBits,
IntPtr.Zero, 0);
}
开发者ID:edisonh,项目名称:Forex-Strategy-Trader,代码行数:7,代码来源:DIBSection.cs
示例3: 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);
}
开发者ID:Mofangbao,项目名称:CSharpGL,代码行数:31,代码来源:DIBSection.cs
示例4: 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;
}
开发者ID:Mofangbao,项目名称:CSharpGL,代码行数:37,代码来源:DIBSection.cs
示例5: DrawText
public static void DrawText(Graphics graphics, string text, Font font, Rectangle bounds, Color color, TextFormatFlags flags, TextStyle textStyle)
{
if (!VisualStyleRenderer.IsSupported) {
TextRenderer.DrawText(graphics, text, font, bounds, color, flags);
return;
}
IntPtr primaryHdc = graphics.GetHdc();
// Create a memory DC so we can work offscreen
IntPtr memoryHdc = CreateCompatibleDC(primaryHdc);
// Create a device-independent bitmap and select it into our DC
BITMAPINFO info = new BITMAPINFO();
info.biSize = Marshal.SizeOf(info);
info.biWidth = bounds.Width;
info.biHeight = -bounds.Height;
info.biPlanes = 1;
info.biBitCount = 32;
info.biCompression = 0; // BI_RGB
IntPtr dib = CreateDIBSection(primaryHdc, info, 0, 0, IntPtr.Zero, 0);
SelectObject(memoryHdc, dib);
// Create and select font
IntPtr fontHandle = font.ToHfont();
SelectObject(memoryHdc, fontHandle);
// Draw glowing text
VisualStyleRenderer renderer = new VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active);
DTTOPTS dttOpts = new DTTOPTS();
dttOpts.dwSize = Marshal.SizeOf(typeof(DTTOPTS));
if (textStyle == TextStyle.Glowing) {
dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
}
else {
dttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR;
}
dttOpts.crText = ColorTranslator.ToWin32(color);
dttOpts.iGlowSize = 8; // This is about the size Microsoft Word 2007 uses
RECT textBounds = new RECT(0, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts);
// Copy to foreground
const int SRCCOPY = 0x00CC0020;
BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY);
// Clean up
DeleteObject(fontHandle);
DeleteObject(dib);
DeleteDC(memoryHdc);
graphics.ReleaseHdc(primaryHdc);
}
开发者ID:kzys,项目名称:Gmail-Notifier-Plus,代码行数:54,代码来源:GlassHelper.cs
示例6: VideoEncoder
/// <summary>
/// 初始化视频编解码器
/// </summary>
/// <param name="bitmapInfoHeader">图像头信息</param>
/// <param name="isEncode">标识完成编码还是解码功能</param>
public VideoEncoder(BITMAPINFOHEADER bitmapInfoHeader, bool isEncode)
{
#region
//BITMAPINFOHEADER bmi = new BITMAPINFOHEADER ();
//bmi.biWidth = bitmapInfoHeader.biWidth;
//bmi.biHeight = bitmapInfoHeader.biHeight;
//if (isEncode)
//{
// bmi.biCompression =bitmapInfoHeader.biCompression;
//}
//else
//{
// bmi.biCompression = FOURCC.MP42;
//}
//bmi.biSizeImage =bitmapInfoHeader.biSizeImage;
//bmi.biPlanes = bitmapInfoHeader.biPlanes;
//bmi.biBitCount = bitmapInfoHeader.biBitCount;
//bmi.biXPelsPerMeter = bitmapInfoHeader.biXPelsPerMeter;
//bmi.biYPelsPerMeter = bitmapInfoHeader.biYPelsPerMeter;
//bmi.biClrUsed = bitmapInfoHeader.biClrUsed;
//bmi.biClrImportant = bitmapInfoHeader.biClrImportant;
//bmi.biSize = bitmapInfoHeader.biSize;
//bitmapInfo.bmiHeader = bmi;
#endregion
BITMAPINFO bitmapInfo = new BITMAPINFO();
bitmapInfo.bmiHeader = bitmapInfoHeader;
this.IsEncode = isEncode;
if (isEncode)
{
COMPVARS compvars = new COMPVARS();
compvars.cbSize = Marshal.SizeOf(compvars);
compvars.dwFlags = 1;
compvars.fccHandler = FOURCC.MP42;
compvars.fccType = FOURCC.ICTYPE_VIDEO;
compvars.lDataRate = 780;
compvars.lKey = 15;
compvars.lQ = -1;
compvars.lQ = 500;
this.Compressor = new ICCompressor(compvars, bitmapInfo, FOURCC.MP42);
this.Compressor.Open();//打开编码器
}
else
{
bitmapInfo.bmiHeader.biCompression = FOURCC.MP42;
this.Decompressor = new ICDecompressor(new COMPVARS(), bitmapInfo, FOURCC.MP42);
this.Decompressor.Open();
}
}
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:56,代码来源:VideoEncoder.cs
示例7: Display
public Display()
{
InitializeComponent();
bmi = new BITMAPINFO
{
biHeader =
{
bihBitCount = 32,
bihPlanes = 1,
bihSize = 40,
bihWidth = 320,
bihHeight = 240,
bihSizeImage = 320 * 240 * 4
}
};
g = pbDisplay.CreateGraphics();
display = pbDisplay;
stopWatch.Start();
}
开发者ID:Sasha7b9,项目名称:Osci,代码行数:22,代码来源:Display.cs
示例8: PixelBuffer
public PixelBuffer(int width, int height)
{
// Create a MemoryDC to hold the bitmap. Use IntPtr.Zero
// to create a device context that is compatible with the screen.
fMemoryDC = GDI32.CreateCompatibleDC(IntPtr.Zero);
// Create a bitmap compatible with the screen
fBitmapInfo = new BITMAPINFO();
fBitmapInfo.Init();
fBitmapInfo.bmiHeader.biWidth = width;
fBitmapInfo.bmiHeader.biHeight = -height;
fBitmapInfo.bmiHeader.biPlanes = 1;
fBitmapInfo.bmiHeader.biBitCount = 32;
fBitmapInfo.bmiHeader.biClrImportant = 0;
fBitmapInfo.bmiHeader.biClrUsed = 0;
fBitmapInfo.bmiHeader.biCompression = GDI32.BI_RGB;
fBitmapInfo.bmiColors = IntPtr.Zero;
fBitmapHandle = GDI32.CreateDIBSection(User32.GetDC(IntPtr.Zero),
ref fBitmapInfo, GDI32.DIB_RGB_COLORS, ref fBits, IntPtr.Zero, 0);
fPixelData = new PixelData(width, height, 32, width * 4, fBits);
// Get the bitmap structure back out so we can
// get our hands on the created pointer and whatnot
//GDI32.GetBitmap(fBitmapHandle, ref fBitmapStructure);
//fBits = fBitmapStructure.bmBits;
// Select the bitmap into the memoryDC
fOldBitmapHandle = GDI32.SelectObject(fMemoryDC, fBitmapHandle);
fAlpha = 255;
}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:36,代码来源:PixelBuffer.cs
示例9: AddHelper
/// <summary>
/// Add or replace an entry in the given image list
/// </summary>
/// <param name="bm">The image</param>
/// <param name="il">The image list to modify</param>
/// <param name="replace">If true replace the existing index with the one given</param>
/// <param name="replaceIndex">The replacement index</param>
private static void AddHelper( Bitmap bm, ImageList il, bool replace, int replaceIndex )
{
IntPtr hBitmap, ppvBits;
BITMAPINFO bmi = new BITMAPINFO();
// Resize the image to dimensions of imagelist before adding
if( bm.Size != il.ImageSize ) {
bm = new Bitmap( bm, il.ImageSize.Width, il.ImageSize.Height );
}
// Required due to the way bitmap is copied and read
bmi.biSize = 40; // Needed for RtlMoveMemory()
bmi.biBitCount = 32; // Number of bits
bmi.biPlanes = 1; // Number of planes
bmi.biWidth = bm.Width; // Width of our new bitmap
bmi.biHeight = bm.Height; // Height of our new bitmap
bm.RotateFlip( RotateFlipType.RotateNoneFlipY );
// Create our new bitmap
hBitmap = CreateDIBSection( new IntPtr( 0 ), bmi, 0,
out ppvBits, new IntPtr( 0 ), 0 );
// Copy the bitmap
BitmapData bitmapData = bm.LockBits( new Rectangle( 0, 0,
bm.Width, bm.Height ), ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb );
RtlMoveMemory( ppvBits, bitmapData.Scan0,
bm.Height * bitmapData.Stride );
bm.UnlockBits( bitmapData );
// Adds the new bitmap to the imagelist control or replaces the existing bitmap
if( replace )
ImageList_Replace( il.Handle, replaceIndex, hBitmap, new IntPtr( 0 ) );
else
ImageList_Add( il.Handle, hBitmap, new IntPtr( 0 ) );
}
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:43,代码来源:ImageListHelper.cs
示例10: CreateDIBSection
static public extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO bmi, uint Usage, out IntPtr bits, IntPtr hSection, uint dwOffset);
开发者ID:ratsil,项目名称:bethe.helpers,代码行数:1,代码来源:WinAPI.cs
示例11: CreateDIBSection
internal static extern IntPtr CreateDIBSection(IntPtr hDC, BITMAPINFO pBMI, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:1,代码来源:PlatformInvoke.cs
示例12: SetDIBitsToDevice
private static extern int SetDIBitsToDevice(IntPtr hdc,
int xDest,
int yDest,
UInt32 dwWidth,
UInt32 dwHeight,
int xSrc,
int ySrc,
UInt32 uStartScan,
UInt32 cScanLines,
IntPtr lpvBits,
ref BITMAPINFO lpbmi,
UInt32 fuColorUse);
开发者ID:hardborn,项目名称:MonitorManager,代码行数:12,代码来源:UC_StandarAndSimpleLayout.cs
示例13: SendBitmapMessage
static extern int SendBitmapMessage(int hWnd, uint wMsg, int wParam, ref BITMAPINFO lParam);
开发者ID:JohannesHoppe,项目名称:clustered-neuronal-network,代码行数:1,代码来源:WebCameraDevice.cs
示例14: SetDIBitsToDevice
private static extern int SetDIBitsToDevice(HandleRef hDC, int xDest, int yDest, int dwWidth, int dwHeight, int XSrc, int YSrc, int uStartScan, int cScanLines, ref int lpvBits, ref BITMAPINFO lpbmi, uint fuColorUse);
开发者ID:Ring-r,项目名称:sandbox,代码行数:1,代码来源:RazorBitmap.cs
示例15: CreateDIBSection
private static extern IntPtr CreateDIBSection(IntPtr hdc,ref BITMAPINFO pbmi, uint iUsage, int ppvBits, IntPtr hSection, uint dwOffset);
开发者ID:SweetX,项目名称:ARKS-Translator,代码行数:1,代码来源:TextOnGlass.GlassText.cs
示例16: DrawTextOnGlass
public static void DrawTextOnGlass(Graphics graphics, string text, Font font, Rectangle bounds,
Color color, TextFormatFlags flags, bool withGlow)
{
IntPtr primaryHdc = graphics.GetHdc();
// Memory DC for off screen rendering.
IntPtr memoryHdc = CreateCompatibleDC(primaryHdc);
BITMAPINFO info = new BITMAPINFO();
info.biSize = Marshal.SizeOf(info);
info.biWidth = bounds.Width;
info.biHeight = -bounds.Height;
info.biPlanes = 1;
info.biBitCount = 32;
info.biCompression = 0; // BI_RGB
IntPtr dib = CreateDIBSection(primaryHdc, info, 0, 0, IntPtr.Zero, 0);
SelectObject(memoryHdc, dib);
IntPtr fontHandle = font.ToHfont();
SelectObject(memoryHdc, fontHandle);
// Draw glowing text if enabled.
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
DTTOPTS dttOpts = new DTTOPTS();
dttOpts.dwSize = (uint)Marshal.SizeOf(typeof(DTTOPTS));
if (withGlow)
{
dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
dttOpts.iGlowSize = 12;
}
else
{
dttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR;
dttOpts.iGlowSize = 0;
}
dttOpts.crText = (uint)ColorTranslator.ToWin32(color);
RECT textBounds = new RECT(dttOpts.iGlowSize, 0, bounds.Width - dttOpts.iGlowSize, bounds.Height);
DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts);
//const int SRCCOPY = 0x00CC0020;
//BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY);
BLENDFUNCTION blend = new Win32.BLENDFUNCTION(AC_SRC_OVER, 0, 255, AC_SRC_ALPHA);
AlphaBlend(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0,
bounds.Width, bounds.Height, blend);
// Clean up
DeleteObject(fontHandle);
DeleteObject(dib);
DeleteDC(memoryHdc);
graphics.ReleaseHdc(primaryHdc);
}
开发者ID:abibell,项目名称:mysql-workbench,代码行数:54,代码来源:Win32.cs
示例17: DrawTextOnGlass
public static void DrawTextOnGlass( IntPtr hwnd, string text, Font font, Rectangle ctlrct, int iglowSize = 10 ) {
if ( !CanUseAero ) {
return;
}
RECT rc = new RECT() {
Left = ctlrct.Left,
Right = ctlrct.Right + 2 * iglowSize,
Top = ctlrct.Top,
Bottom = ctlrct.Bottom + 2 * iglowSize,
};
RECT rc2 = new RECT() {
Left = 0,
Top = 0,
Right = rc.Right - rc.Left,
Bottom = rc.Bottom - rc.Top
};
IntPtr destdc = GetDC( hwnd );
IntPtr Memdc = CreateCompatibleDC( destdc );
IntPtr bitmap;
IntPtr bitmapOld = IntPtr.Zero;
IntPtr logfnotOld;
int uFormat = DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX;
BITMAPINFO dib = new BITMAPINFO() {
bmiHeader = new BITMAPINFOHEADER() {
biHeight = -( rc.Bottom - rc.Top ),
biWidth = rc.Right - rc.Left,
biPlanes = 1,
biSize = Marshal.SizeOf( typeof( BITMAPINFOHEADER ) ),
biBitCount = 32,
biCompression = BI_RGB
}
};
if ( SaveDC( Memdc ) != 0 ) {
bitmap = CreateDIBSection( Memdc, ref dib, DIB_RGB_COLORS, 0, IntPtr.Zero, 0 ); // Create a 32-bit bmp for use in offscreen drawing when glass is on
if ( bitmap != IntPtr.Zero ) {
bitmapOld = SelectObject( Memdc, bitmap );
IntPtr hFont = font.ToHfont();
logfnotOld = SelectObject( Memdc, hFont );
try {
VisualStyleRenderer renderer = new VisualStyleRenderer( VisualStyleElement.Window.Caption.Active );
DTTOPTS dttOpts = new DTTOPTS() {
dwSize = ( uint ) Marshal.SizeOf( typeof( DTTOPTS ) ),
dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE,
iGlowSize = iglowSize
};
DrawThemeTextEx( renderer.Handle, Memdc, 0, 0, text, -1, uFormat, ref rc2, ref dttOpts );
BitBlt( destdc, rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top, Memdc, 0, 0, SOURCE_COPY );
}
catch ( Exception e ) {
Logger.LogError( e );
}
finally {
try {
SelectObject( Memdc, bitmapOld );
SelectObject( Memdc, logfnotOld );
DeleteObject( bitmap );
DeleteObject( hFont );
ReleaseDC( Memdc, -1 );
DeleteDC( Memdc );
}
catch { }
}
}
}
}
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:78,代码来源:Natives.cs
示例18: FillBlackRegion
public static void FillBlackRegion( Graphics gph, Rectangle rgn ) {
RECT rc = new RECT() {
Left = rgn.Left,
Right = rgn.Right,
Top = rgn.Top,
Bottom = rgn.Bottom,
};
IntPtr destdc = gph.GetHdc();
IntPtr Memdc = CreateCompatibleDC( destdc );
IntPtr bitmap;
IntPtr bitmapOld = IntPtr.Zero;
BITMAPINFO dib = new BITMAPINFO() {
bmiHeader = new BITMAPINFOHEADER() {
biHeight = -( rc.Bottom - rc.Top ),
biWidth = rc.Right - rc.Left,
biPlanes = 1,
biSize = Marshal.SizeOf( typeof( BITMAPINFOHEADER ) ),
biBitCount = 32,
biCompression = BI_RGB
}
};
if ( SaveDC( Memdc ) != 0 ) {
bitmap = CreateDIBSection( Memdc, ref dib, DIB_RGB_COLORS, 0, IntPtr.Zero, 0 );
try {
if ( bitmap != IntPtr.Zero ) {
bitmapOld = SelectObject( Memdc, bitmap );
BitBlt( destdc, rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top, Memdc, 0, 0, SOURCE_COPY );
}
}
finally {
SelectObject( Memdc, bitmapOld );
DeleteObject( bitmap );
ReleaseDC( Memdc, -1 );
DeleteDC( Memdc );
}
}
gph.ReleaseHdc();
}
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:44,代码来源:Natives.cs
示例19: SetRemoteBITMAPINFOHEADER
/// <summary>
/// 设置对方视频格式事件
/// </summary>
/// <param name="BITMAPINFO"></param>
public void SetRemoteBITMAPINFOHEADER(BITMAPINFO BITMAPINFO)
{
if (VD == null)
VD = new VideoEncoder(BITMAPINFO, false);//创建视频解码器
if (VR == null)
{
VR = new VideoRender(this.cRemote);//创建视频回显组件
VR.IniVideoRender(BITMAPINFO.bmiHeader);
}
}
开发者ID:cheehwasun,项目名称:ourmsg,代码行数:15,代码来源:AVComponent.cs
示例20: CreateDIBSection
public static extern SafeGDIHandle CreateDIBSection(IntPtr hdc, BITMAPINFO pbmi, uint iUsage, IntPtr ppvBits, IntPtr hSection, uint dwOffset);
开发者ID:RogovaTatiana,项目名称:FilesSync,代码行数:1,代码来源:NativeMethods.cs
注:本文中的BITMAPINFO类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论