나는이 거의 존재입니다 ... :) 내가 가진투명한 사각형을 그리려면 어떻게해야합니까?
내 자신의 이중 버퍼를 구현합니다 ...
그래서 내가 비트 맵을 만들 :if (_Bitmap != null) _Bitmap.Dispose();
if (_Graphics != null) _Graphics.Dispose();
_Bitmap = new Bitmap(Bounds.Width, Bounds.Height);
_Bitmap.MakeTransparent(Color.Transparent);
_Graphics = Graphics.FromImage(_Bitmap);
_Graphics.FillRectangle(Brushes.Transparent, Bounds);
내가 가질 수 있다고 생각 비트 맵을 투명하게 수동으로 설정합니다. 내 처리기의 OnPaint 방법에서
은이 수행합니다
protected override void OnPaint(PaintEventArgs e)
{
if (_pDevice != null)
{
try
{
_pDevice.update();
_Graphics.ReleaseHdc();
if (_bZoomWindow)
{
//_Graphics.DrawRectangle(_selectionPen, _rcRubberBand);
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddRectangle(_rcRubberBand);
gp.Widen(_selectionPen);
_Graphics.FillPath(Brushes.WhiteSmoke, gp);
}
}
OdRxDictionary Properties = _graphicsDevice.properties();
//if (helperDevice.UnderlyingDevice.Properties.Contains("WindowHDC"))
// helperDevice.UnderlyingDevice.Properties.AtPut("WindowHDC", new RxVariant((Int32)graphics.GetHdc()));
if (Properties.ContainsKey("WindowHDC"))
Properties.putAt("WindowHDC", new OdRxVariantValue(_Graphics.GetHdc().ToInt32())); // hWnd necessary for DirectX device
}
catch (System.Exception ex)
{
_Graphics.DrawString(ex.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), new PointF(150.0F, 150.0F));
}
e.Graphics.DrawImageUnscaled(_Bitmap, 0, 0);
}
}
문제는 사각형 검은 배경으로 그리기된다는 점이다. 그래서 비트 맵에 그 아래 도면이다 죽이고있다 :
가 어떻게 그냥 사각형을 그릴 수 있습니까? 내가 뭘 놓치고 있니? 이것이 바보 같은 질문이라면 유감입니다! 투명성 페인팅
는
제가 생각하기에 Graphics.DrawRectangle 메서드가 그 선들을 그릴 것입니다 ... – jimbobmcgee
FillRectangle (Brushes.Transparent ..는 작동해야하지만 불행히도 픽셀을 투명하게 만드십시오. 더 깊어지는 루틴이 필요합니다. 한 가지 간단한 해결 방법은 앤티 앨리어싱을 끄고 필요없는 이상한 색상을 그려서 maketransparent라고 부르는 것입니다. – TaW
@TaW 나는 제안에 개방적이다. 만약 내가 4 줄씩 하나씩 그리면? –