private void PaintLine(HCCanvas canvas, RECT drawRect) { int vTop = (drawRect.Top + drawRect.Bottom) / 2; canvas.MoveTo(drawRect.Left, vTop); canvas.LineTo(drawRect.Right, vTop); }
protected override void DoDrawItemPaintAfter(HCCustomData aData, int aItemNo, int aDrawItemNo, RECT aDrawRect, RECT aClearRect, int aDataDrawLeft, int aDataDrawRight, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoDrawItemPaintAfter(aData, aItemNo, aDrawItemNo, aDrawRect, aClearRect, aDataDrawLeft, aDataDrawRight, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, ACanvas, APaintInfo); }
protected override void DoDrawItemPaintAfter(HCCustomData AData, int ADrawItemNo, RECT ADrawRect, int ADataDrawLeft, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoDrawItemPaintAfter(AData, ADrawItemNo, ADrawRect, ADataDrawLeft, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, ACanvas, APaintInfo); }
/// <summary> 绘制数据 </summary> /// <param name="ADataDrawLeft">绘制目标区域Left</param> /// <param name="ADataDrawTop">绘制目标区域的Top</param> /// <param name="ADataDrawBottom">绘制目标区域的Bottom</param> /// <param name="ADataScreenTop">屏幕区域Top</param> /// <param name="ADataScreenBottom">屏幕区域Bottom</param> /// <param name="AVOffset">指定从哪个位置开始的数据绘制到目标区域的起始位置</param> /// <param name="ACanvas">画布</param> public void PaintData(int ADataDrawLeft, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, int AVOffset, HCCanvas ACanvas, PaintInfo APaintInfo) { if (FCellData != null) { int vTop = 0; switch (FAlignVert) { case View.AlignVert.cavTop: vTop = ADataDrawTop; break; case View.AlignVert.cavBottom: vTop = ADataDrawTop + FHeight - FCellData.Height; break; case View.AlignVert.cavCenter: vTop = ADataDrawTop + (FHeight - FCellData.Height) / 2; break; } FCellData.PaintData(ADataDrawLeft, vTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, AVOffset, ACanvas, APaintInfo); } }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { // 绘制二维码 base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, ACanvas, APaintInfo); }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { FCode128.PaintTo(aCanvas, aDrawRect); base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); }
private RECT GetAreaRect(DateTimeArea aArea) { RECT Result = new RECT(0, 0, 0, 0); if (aArea == DateTimeArea.dtaNone) { return(Result); } //int vCharOffset = 0; //int vAppendLevel = 0; HCCanvas vCanvas = HCStyle.CreateStyleCanvas(); try { this.OwnerData.Style.TextStyles[this.TextStyleNo].ApplyStyle(vCanvas); if (FFormat != "") { AppendFormat(vCanvas, aArea, ref Result); } //else // AppendFormat(ref Result, "C"); // 用短格式显示日期与时间 } finally { HCStyle.DestroyStyleCanvas(vCanvas); } return(Result); }
public virtual void SaveToBitmap(ref Bitmap aBitmap) { aBitmap = new Bitmap(FWidth, FHeight); PaintInfo vPaintInfo = new PaintInfo(); vPaintInfo.Print = true; vPaintInfo.WindowWidth = aBitmap.Width; vPaintInfo.WindowHeight = aBitmap.Height; vPaintInfo.ScaleX = 1; vPaintInfo.ScaleY = 1; vPaintInfo.Zoom = 1; Graphics vGraphic = Graphics.FromImage(aBitmap); IntPtr vDC = vGraphic.GetHdc(); try { HCCanvas vCanvas = new HCCanvas(vDC); try { this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height), 0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo); } finally { vCanvas.Dispose(); } } finally { vGraphic.ReleaseHdc(); } }
private void DoPopupFormPaint() { if (FOnPaint != null) { PAINTSTRUCT vPaintStruct = new PAINTSTRUCT(); IntPtr vDC = (IntPtr)User.BeginPaint(FPopupWindow, ref vPaintStruct); try { HCCanvas vCanvas = new HCCanvas(vDC); try { RECT vRect = new RECT(); User.GetClientRect(FPopupWindow, ref vRect); FOnPaint(vCanvas, vRect); } finally { vCanvas.Dispose(); } } finally { User.EndPaint(FPopupWindow, ref vPaintStruct); } } }
public void PaintTo(HCCanvas aCanvas, int aLeft, int aTop) { FLeft = aLeft; FTop = aTop; GDI.BitBlt(aCanvas.Handle, FLeft, FTop, FGraphic.Width, FGraphic.Height, FGraphicCanvas.Handle, 0, 0, GDI.SRCCOPY); }
public override void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Color = Color; aCanvas.Pen.Width = FWidth; aCanvas.Pen.Style = FLineStyle; } finally { aCanvas.Pen.EndUpdate(); } aCanvas.MoveTo(FPoints[0].X + aRect.Left, FPoints[0].Y + aRect.Top); for (int i = 1; i < FPoints.Count; i++) { aCanvas.LineTo(FPoints[i].X + aRect.Left, FPoints[i].Y + aRect.Top); } if (FPoints.Count > 1) // 首尾相连 { aCanvas.LineTo(FPoints[0].X + aRect.Left, FPoints[0].Y + aRect.Top); } if ((!aPaintInfo.Print) && this.Active) { PaintAnchor(aCanvas, aRect); } }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { base.DoPaint(AStyle, ADrawRect, ADataDrawTop, ADataDrawBottom, ADataScreenTop, ADataScreenBottom, ACanvas, APaintInfo); FButtonDrawRect = FButtonRect; FButtonDrawRect.Offset(ADrawRect.Left, ADrawRect.Top); if (FMouseInButton) { ACanvas.Brush.Color = HC.clMenu; } else { ACanvas.Brush.Color = HC.clWindow; } ACanvas.FillRect(FButtonDrawRect); ACanvas.Pen.Color = Color.Black; int vLeft = FButtonDrawRect.Left + (BTNWIDTH - 7) / 2; int vTop = FButtonDrawRect.Top + (FButtonDrawRect.Height - 4) / 2; for (int i = 0; i <= 3; i++) { ACanvas.MoveTo(vLeft, vTop); ACanvas.LineTo(vLeft + 7 - i - i, vTop); vLeft++; vTop++; } }
public void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { for (int i = 0; i < this.Count; i++) { this[i].PaintTo(aCanvas, aRect, aPaintInfo); } }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { ACanvas.Pen.BeginUpdate(); try { ACanvas.Pen.Color = Color.Black; ACanvas.Pen.Style = HCPenStyle.psSolid; } finally { ACanvas.Pen.EndUpdate(); } ACanvas.MoveTo(FStartPt.X + this.DrawRect.Left, FStartPt.Y + this.DrawRect.Top); ACanvas.LineTo(FEndPt.X + this.DrawRect.Left, FEndPt.Y + this.DrawRect.Top); if ((this.Active) && (!APaintInfo.Print)) // 激活 { ACanvas.Rectangle(FStartPt.X + this.DrawRect.Left - PointSize, FStartPt.Y + this.DrawRect.Top - PointSize, FStartPt.X + this.DrawRect.Left + PointSize, FStartPt.Y + this.DrawRect.Top + PointSize); ACanvas.Rectangle(FEndPt.X + this.DrawRect.Left - PointSize, FEndPt.Y + this.DrawRect.Top - PointSize, FEndPt.X + this.DrawRect.Left + PointSize, FEndPt.Y + this.DrawRect.Top + PointSize); } }
public void ApplyStyle(HCCanvas ACanvas, Single AScale = 1) { ACanvas.Brush.Color = FBackColor; ACanvas.Font.BeginUpdate(); try { ACanvas.Font.Color = FColor; ACanvas.Font.Family = FFamily; if ((FFontStyles.Contains((byte)HCFontStyle.tsSuperscript)) || (FFontStyles.Contains((byte)HCFontStyle.tsSubscript))) { ACanvas.Font.Size = FSize / 2; } else { ACanvas.Font.Size = FSize; } ACanvas.Font.FontStyles = FFontStyles; } finally { ACanvas.Font.EndUpdate(); } }
public override void PaintTo(HCCanvas aCanvas, RECT aRect, PaintInfo aPaintInfo) { aCanvas.Pen.BeginUpdate(); try { aCanvas.Pen.Color = Color; aCanvas.Pen.Width = Width; aCanvas.Pen.Style = LineStyle; } finally { aCanvas.Pen.EndUpdate(); } if (BackColor == HC.HCTransparentColor) { aCanvas.Brush.Style = HCBrushStyle.bsClear; } aCanvas.Ellipse(StartPt.X + aRect.Left, StartPt.Y + aRect.Top, EndPt.X + aRect.Left, EndPt.Y + aRect.Top); if (!aPaintInfo.Print && this.Active) { PaintAnchor(aCanvas, aRect); } }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); if (FMouseIn) { aCanvas.Brush.Color = HC.clBtnFace; aCanvas.FillRect(aDrawRect); } aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom); POINT vPoint = new POINT(); RECT vItemRect = new RECT(); for (int i = 0; i <= FItems.Count - 1; i++) { vPoint.X = FItems[i].Position.X; vPoint.Y = FItems[i].Position.Y; vPoint.Offset(aDrawRect.Left, aDrawRect.Top); vItemRect = HC.Bounds(vPoint.X, vPoint.Y, RadioButtonWidth, RadioButtonWidth); if (FItems[i].Checked) { User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_CHECKED | Kernel.DFCS_BUTTONRADIO); } else { User.DrawFrameControl(aCanvas.Handle, ref vItemRect, Kernel.DFC_BUTTON, Kernel.DFCS_BUTTONRADIO); } aCanvas.TextOut(vPoint.X + RadioButtonWidth, vPoint.Y, FItems[i].Text); } }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); if (this.IsSelectComplate) { aCanvas.Brush.Color = aStyle.SelColor; } else if (FDown) { aCanvas.Brush.Color = HC.clHighlight; } else if (FMouseIn) { aCanvas.Brush.Color = HC.clBtnFace; } else { aCanvas.Brush.Color = HC.clMedGray; } aCanvas.FillRect(aDrawRect); aCanvas.Brush.Style = HCBrushStyle.bsClear; aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom); SIZE vSize = aCanvas.TextExtent(FText); aCanvas.TextOut(aDrawRect.Left + (aDrawRect.Width - vSize.cx) / 2, aDrawRect.Top + (aDrawRect.Height - vSize.cy) / 2, FText); }
public virtual bool SaveToBitmap(ref Bitmap aBitmap) { if ((FWidth == 0) || (FHeight == 0)) { return(false); } aBitmap = new Bitmap(FWidth, FHeight); PaintInfo vPaintInfo = new PaintInfo(); vPaintInfo.Print = true; vPaintInfo.WindowWidth = aBitmap.Width; vPaintInfo.WindowHeight = aBitmap.Height; vPaintInfo.ScaleX = 1; vPaintInfo.ScaleY = 1; vPaintInfo.Zoom = 1; using (HCCanvas vCanvas = new HCCanvas()) { vCanvas.Graphics = Graphics.FromImage(aBitmap); vCanvas.Brush.Color = Color.White; vCanvas.FillRect(new RECT(0, 0, aBitmap.Width, aBitmap.Height)); this.DoPaint(OwnerData.Style, new RECT(0, 0, aBitmap.Width, aBitmap.Height), 0, aBitmap.Height, 0, aBitmap.Height, vCanvas, vPaintInfo); vCanvas.Dispose(); } return(true); }
public static int GetNorAlignCharOffsetAt(HCCanvas aCanvas, string aText, int x) { int Result = -1; if (x < 0) Result = 0; else { int vLen = aText.Length; int[] vCharWArr = new int[vLen]; SIZE vSize = new SIZE(0, 0); aCanvas.GetTextExtentExPoint(aText, vLen, vCharWArr, ref vSize); if (x > vSize.cx) Result = vLen; else { int i = 1; while (i <= vLen) { #if UNPLACEHOLDERCHAR i = HC.GetTextActualOffset(aText, i, true); #endif if (x == vCharWArr[i - 1]) { Result = i; break; } else if (x > vCharWArr[i - 1]) i++; else { if (x > HC.GetCharHalfFarfrom( #if UNPLACEHOLDERCHAR aText, #endif i, vCharWArr)) { Result = i; } else { #if UNPLACEHOLDERCHAR Result = HC.GetTextActualOffset(aText, i) - 1; #else Result = i - 1; #endif } break; } } } } return Result; }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { if (this.Active) { aCanvas.DrawFocuseRect(FDrawRect); } }
protected override void DoPaint(HCStyle AStyle, RECT ADrawRect, int ADataDrawTop, int ADataDrawBottom, int ADataScreenTop, int ADataScreenBottom, HCCanvas ACanvas, PaintInfo APaintInfo) { if (this.Active) { ACanvas.DrawFocuseRect(FDrawRect); } }
protected override void DoPaint(HCStyle aStyle, RECT aDrawRect, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, HCCanvas aCanvas, PaintInfo aPaintInfo) { base.DoPaint(aStyle, aDrawRect, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aCanvas, aPaintInfo); if (this.IsSelectComplate && (!aPaintInfo.Print)) { aCanvas.Brush.Color = aStyle.SelColor; aCanvas.FillRect(aDrawRect); } aStyle.TextStyles[TextStyleNo].ApplyStyle(aCanvas, aPaintInfo.ScaleY / aPaintInfo.Zoom); if (!this.AutoSize) { aCanvas.TextRect(aDrawRect, aDrawRect.Left + FMargin, aDrawRect.Top + FMargin, FText); } else { aCanvas.TextOut(aDrawRect.Left + FMargin, aDrawRect.Top + FMargin, FText); } if (FMouseIn && (!aPaintInfo.Print)) { aCanvas.Pen.Color = Color.Blue; } else // 鼠标不在其中或打印 { aCanvas.Pen.Color = Color.Black; } aCanvas.Pen.Width = FBorderWidth; if (FBorderSides.Contains((byte)BorderSide.cbsLeft)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Left, aDrawRect.Bottom); } if (FBorderSides.Contains((byte)BorderSide.cbsTop)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Right, aDrawRect.Top); } if (FBorderSides.Contains((byte)BorderSide.cbsRight)) { aCanvas.MoveTo(aDrawRect.Right, aDrawRect.Top); aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom); } if (FBorderSides.Contains((byte)BorderSide.cbsBottom)) { aCanvas.MoveTo(aDrawRect.Left, aDrawRect.Bottom); aCanvas.LineTo(aDrawRect.Right, aDrawRect.Bottom); } }
// 类内部方法 private void ApplySupSubStyle(HCTextStyle aTextStyle, HCCanvas aCanvas, Single aScale = 1) { if (aTextStyle.BackColor == HC.HCTransparentColor) { aCanvas.Brush.Style = HCBrushStyle.bsClear; } else { aCanvas.Brush.Color = aTextStyle.BackColor; } aCanvas.Font.BeginUpdate(); try { aCanvas.Font.Color = aTextStyle.Color; aCanvas.Font.Family = aTextStyle.Family; aCanvas.Font.Size = (int)Math.Round(aTextStyle.Size * 2 / 3f); if (aTextStyle.FontStyles.Contains((byte)HCFontStyle.tsBold)) { aCanvas.Font.FontStyles.InClude((byte)HCFontStyle.tsBold); } else { aCanvas.Font.FontStyles.ExClude((byte)HCFontStyle.tsBold); } if (aTextStyle.FontStyles.Contains((byte)HCFontStyle.tsItalic)) { aCanvas.Font.FontStyles.InClude((byte)HCFontStyle.tsItalic); } else { aCanvas.Font.FontStyles.ExClude((byte)HCFontStyle.tsItalic); } if (aTextStyle.FontStyles.Contains((byte)HCFontStyle.tsUnderline)) { aCanvas.Font.FontStyles.InClude((byte)HCFontStyle.tsUnderline); } else { aCanvas.Font.FontStyles.ExClude((byte)HCFontStyle.tsUnderline); } if (aTextStyle.FontStyles.Contains((byte)HCFontStyle.tsStrikeOut)) { aCanvas.Font.FontStyles.InClude((byte)HCFontStyle.tsStrikeOut); } else { aCanvas.Font.FontStyles.ExClude((byte)HCFontStyle.tsStrikeOut); } } finally { aCanvas.Font.EndUpdate(); } }
public void UpdateView() { if ((FUpdateCount == 0) && IsHandleCreated) { if (FMemDC != IntPtr.Zero) { GDI.DeleteDC(FMemDC); } FMemDC = (IntPtr)GDI.CreateCompatibleDC(FDC); int vViewWidth = GetViewWidth(); int vViewHeight = GetViewHeight(); IntPtr vBitmap = (IntPtr)GDI.CreateCompatibleBitmap(FDC, vViewWidth, vViewHeight); GDI.SelectObject(FMemDC, vBitmap); try { using (HCCanvas vDataBmpCanvas = new HCCanvas(FMemDC)) { // 控件背景 vDataBmpCanvas.Brush.Color = Color.White;// $00E7BE9F; vDataBmpCanvas.FillRect(new RECT(0, 0, vViewWidth, vViewHeight)); PaintInfo vPaintInfo = new PaintInfo(); try { FData.PaintData(this.Padding.Left - FHScrollBar.Position, // 当前页数据要绘制到的Left this.Padding.Top, // 当前页数据要绘制到的Top this.Width - FHScrollBar.Position - this.Padding.Right, this.Padding.Top + FData.Height, // 当前页数据要绘制的Bottom this.Padding.Top, // 界面呈现当前页数据的Top位置 this.Height - FHScrollBar.Height, // 界面呈现当前页数据Bottom位置 FVScrollBar.Position, // 指定从哪个位置开始的数据绘制到页数据起始位置 vDataBmpCanvas, vPaintInfo); for (int i = 0; i <= vPaintInfo.TopItems.Count - 1; i++) // 绘制顶层Ite { vPaintInfo.TopItems[i].PaintTop(vDataBmpCanvas); } } finally { vPaintInfo.Dispose(); } GDI.BitBlt(FDC, 0, 0, vViewWidth, vViewHeight, FMemDC, 0, 0, GDI.SRCCOPY); } } finally { GDI.DeleteObject(vBitmap); } RECT vRect = new RECT(0, 0, vViewWidth, vViewHeight); User.InvalidateRect(this.Handle, ref vRect, 0); // 只更新变动区域,防止闪烁,解决BitBlt光标滞留问题 User.UpdateWindow(this.Handle); } }
public static HCCanvas CreateStyleCanvas() { //IntPtr vScreenDC = User.GetDC(IntPtr.Zero); IntPtr vDC = (IntPtr)GDI.CreateCompatibleDC(IntPtr.Zero); HCCanvas Result = new HCCanvas(vDC); return(Result); }
private void DoImageToolBarUpdateView(RECT aRect, HCCanvas aCanvas) { if (this.IsHandleCreated && (FImageToolBar != null)) { RECT vRect = aRect; vRect.Offset(FImageToolBar.Left, FImageToolBar.Top); UpdateView(vRect); } }
public override void PaintData(int aDataDrawLeft, int aDataDrawTop, int aDataDrawBottom, int aDataScreenTop, int aDataScreenBottom, int aVOffset, int aFirstDItemNo, int aLastDItemNo, HCCanvas aCanvas, PaintInfo aPaintInfo) { CheckAnnotateRange(aFirstDItemNo, aLastDItemNo); // 指定DrawItem范围内的批注获取各自的DrawItem范围 base.PaintData(aDataDrawLeft, aDataDrawTop, aDataDrawBottom, aDataScreenTop, aDataScreenBottom, aVOffset, aFirstDItemNo, aLastDItemNo, aCanvas, aPaintInfo); FDrawItemAnnotates.Clear(); }
protected override void OnPaint(PaintEventArgs e) { ///////base.OnPaint(e); using (HCCanvas vCanvas = new HCCanvas()) { vCanvas.Graphics = e.Graphics; PaintToEx(vCanvas); } }
public override void PaintTop(HCCanvas aCanvas) { if (this.Resizing) { Bitmap vBitmap = FImage; //如果原图片是索引像素格式之列的,则需要转换 if (IsPixelFormatIndexed(FImage.PixelFormat)) { vBitmap = new Bitmap(FImage.Width, FImage.Height, PixelFormat.Format32bppArgb); } using (Graphics vGraphicSrc = Graphics.FromImage(vBitmap)) { BLENDFUNCTION vBlendFunction = new BLENDFUNCTION(); vBlendFunction.BlendOp = GDI.AC_SRC_OVER; vBlendFunction.BlendFlags = 0; vBlendFunction.AlphaFormat = GDI.AC_SRC_OVER; // 通常为 0,如果源位图为32位真彩色,可为 AC_SRC_ALPHA vBlendFunction.SourceConstantAlpha = 128; // 透明度 IntPtr vImageHDC = vGraphicSrc.GetHdc(); try { IntPtr vMemDC = (IntPtr)GDI.CreateCompatibleDC(vImageHDC); IntPtr vHbitmap = FImage.GetHbitmap();// (IntPtr)GDI.CreateCompatibleBitmap(vImageHDC, FImage.Width, FImage.Height); GDI.SelectObject(vMemDC, vHbitmap); GDI.AlphaBlend( aCanvas.Handle, ResizeRect.Left, ResizeRect.Top, ResizeWidth, ResizeHeight, vMemDC, 0, 0, FImage.Width, FImage.Height, vBlendFunction); GDI.DeleteDC(vMemDC); GDI.DeleteObject(vHbitmap); } finally { vGraphicSrc.ReleaseHdc(vImageHDC); } } if (!vBitmap.Equals(FImage)) { vBitmap.Dispose(); } } base.PaintTop(aCanvas); }