zoukankan      html  css  js  c++  java
  • 快速加载背景图片(解决大量控件时闪烁)

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            PanelEnhanced panelEnhanced = new PanelEnhanced();
            this.Controls.Add(panelEnhanced);
            panelEnhanced.Dock = DockStyle.Fill;
            panelEnhanced.BackgroundImage = Image.FromFile(@"D:pic.jpg");
        }
    }
    
    class PanelEnhanced : Panel
    {
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            return;
        }
    
        protected override void OnPaint(PaintEventArgs e)
        {
            this.DoubleBuffered = true;
            if (this.BackgroundImage != null)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                e.Graphics.DrawImage(
                    this.BackgroundImage,
                    new System.Drawing.Rectangle(0, 0, this.Width, this.Height),
                    0,
                    0,
                    this.BackgroundImage.Width,
                    this.BackgroundImage.Height,
                    System.Drawing.GraphicsUnit.Pixel);
            }
            base.OnPaint(e);
        }
    }
  • 相关阅读:
    12.1
    11.26
    12.5Java日报
    11.25
    11.27
    12.03
    11.28
    12.04
    如何在TortoiseGit中使用sshkeygen生成的key
    leetcode 39 组合总和
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10931121.html
Copyright © 2011-2022 走看看