protected override void OnPaint(PaintEventArgs e) { Graphics g_main = e.Graphics; g_main.SmoothingMode = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿 g_main.InterpolationMode = InterpolationMode.HighQualityBicubic; g_main.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量 Rectangle rect = this.ClientRectangle; using (Bitmap bitmap = new Bitmap(rect.Width, rect.Height + dimHeight)) { int last = chatVScroll.Bounds.Y + chatVScroll.Value; int first = last - (300 + dimHeight); List <WebVideoListItem> _Items = Items.FindAll(db => (db.Bounds.Y > first && db.Bounds.Y - last < rect.Height)); using (Graphics g = Graphics.FromImage(bitmap)) { g.TranslateTransform(0, -(chatVScroll.Value - dimHeight)); //根据滚动条的值设置坐标偏移 g.SmoothingMode = SmoothingMode.HighQuality; //使绘图质量最高,即消除锯齿 g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量 foreach (WebVideoListItem it in _Items) { if (it.IsRender) { if (it.Img != null) { g.DrawImage(it.Img, it.Bounds); } else { g.FillRectangle(FontColor1, it.Bounds); g.DrawString(FontAwesome.GetUnicode("51BC"), onA, FontColor2, it.Bounds, _StringFormatC); } g.FillRectangle(solidBrush3, it.NameBound); g.DrawString(it.Name, on, FontColor1, it.NameBound, _StringFormat); if (it.MouseHover) { g.FillRectangle(solidBrush, it.Bounds); g.DrawString(FontAwesome.GetUnicode("518F"), onA, FontColor1, it.Bounds, _StringFormatC); } if (it.Select) { g.DrawRectangle(pen, it.Bound); //g.FillRectangle(yllosolidBrush, it.Bounds); } } } //g.ResetTransform();//重置坐标系 } //if (bitmapTop != null) { // bitmapTop.Dispose(); //} if (dimHeight > 0 && TopChange != null && _Items.Count > 0) { Bitmap bitmapTop = new Bitmap(rect.Width, dimHeight); Rectangle rectTop = new Rectangle(0, 0, rect.Width, dimHeight); using (Graphics gTop = Graphics.FromImage(bitmapTop)) { //gTop.SmoothingMode = SmoothingMode.AntiAlias;//使绘图质量最高,即消除锯齿 //gTop.InterpolationMode = InterpolationMode.HighQualityBicubic; ////g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; //gTop.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量 gTop.DrawImage(bitmap, rectTop, rectTop, GraphicsUnit.Pixel); } //if (Bmp != null) //{ // Bmp.Dispose(); // Marshal.FreeHGlobal(ImageCopyPointer); //} Rectangle Rect = new Rectangle(0, 0, bitmapTop.Width, bitmapTop.Height); bitmapTop.GaussianBlur(ref Rect, 80, false); using (Graphics gTop = Graphics.FromImage(bitmapTop)) { gTop.FillRectangle(solidBrush2, rectTop); } //Bmp.UsmSharpen(ref Rect, BarRadius.Value, BarAmount.Value); TopChange(bitmapTop); } g_main.DrawImage(bitmap, rect, new Rectangle(0, dimHeight, rect.Width, rect.Height), GraphicsUnit.Pixel); //g_main.DrawImage(bitmap, rect, new Rectangle(0, 0, rect.Width, rect.Height + 40), GraphicsUnit.Pixel); if (chatVScroll.ShouldBeDraw)//是否绘制滚动条 { chatVScroll.ReDrawScroll(g_main); } } base.OnPaint(e); }