当前位置: 首页>>代码示例>>C#>>正文


C# BITMAPINFO类代码示例

本文整理汇总了C#中BITMAPINFO的典型用法代码示例。如果您正苦于以下问题:C# BITMAPINFO类的具体用法?C# BITMAPINFO怎么用?C# BITMAPINFO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BITMAPINFO类属于命名空间,在下文中一共展示了BITMAPINFO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的BITMAPINFO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。