Source/BufferedBitmap.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;

namespace DevComponents.DotNetBar
{
    public class BufferedBitmap : IDisposable
    {
        #region Private Variables
        private Rectangle m_TargetRect = Rectangle.Empty;
        private IntPtr m_MemDC = IntPtr.Zero;
        private Graphics m_BitmapGraphics = null;
        private IntPtr m_MemDib = IntPtr.Zero;
        #endregion

        #region Internal Implementation
        public BufferedBitmap(Graphics source, Rectangle rect)
        {
            IntPtr hdc = source.GetHdc();
            try
            {
                Initialize(hdc, rect);
            }
            finally
            {
                source.ReleaseHdc(hdc);
            }
        }

        public Graphics Graphics
        {
            get
            {
                return m_BitmapGraphics;
            }
        }

        public BufferedBitmap(IntPtr hdcSource, Rectangle rect)
        {
            Initialize(hdcSource, rect);
        }
        private void Initialize(IntPtr hdcSource, Rectangle r)
        {
            m_TargetRect = r;

            m_MemDC = WinApi.CreateCompatibleDC(hdcSource);
            WinApi.BITMAPINFO info = new WinApi.BITMAPINFO();
            info.biWidth = r.Width;
            info.biHeight = r.Height;
            info.biPlanes = 1;
            info.biBitCount = 32;
            info.biSize = Marshal.SizeOf(info);
            m_MemDib = WinApi.CreateDIBSection(hdcSource, info, 0, 0, IntPtr.Zero, 0);
            WinApi.SelectObject(m_MemDC, m_MemDib);
            m_BitmapGraphics = Graphics.FromHdc(m_MemDC);
        }

        public void Render(Graphics targetGraphics)
        {
后面还有 63 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。